多Agent场景,子agent 之间数据读写不同步,如何解决?
01
单 Agent 与多 Agent 的读写设计有何异同?
02
Milvus如何用四档一致性控制数据对外可见的时机
03
实验:Bounded 查不到,Strong 查得到
实验设计思路
preload预写:提前写入大批量数据,制造WAL(Write-Ahead Log)历史积压; storm writers后台写入:用多个后台线程持续高速写入数据,维持Query Node的追赶压力。
#!/usr/bin/env python3import argparseimport itertoolsimport randomimport threadingimport timeimport uuidfrom contextlib import suppressfrom pymilvus import DataType, MilvusClientdef make_vector(seed, dim): rng = random.Random(seed) vec = [rng.uniform(-1.0, 1.0) for _ in range(dim)] norm = sum(x * x for x in vec) ** 0.5 or 1.0 return [x / norm for x in vec]def make_records(start_id, count, dim, marker, round_no): return [ { "id": start_id + i, "vector": make_vector(start_id + i, dim), "marker": marker, "round": round_no, } for i in range(count) ]def create_collection(client, name, dim): if client.has_collection(name): client.drop_collection(name) schema = client.create_schema(auto_id=False, enable_dynamic_field=False) schema.add_field("id", DataType.INT64, is_primary=True) schema.add_field("vector", DataType.FLOAT_VECTOR, dim=dim) schema.add_field("marker", DataType.VARCHAR, max_length=128) schema.add_field("round", DataType.INT64) index_params = client.prepare_index_params() index_params.add_index( field_name="vector", index_type="AUTOINDEX", metric_type="COSINE", ) client.create_collection( collection_name=name, schema=schema, index_params=index_params, consistency_level="Bounded", ) client.load_collection(name)def search_marker(client, name, vector, marker, consistency, timeout): result = client.search( collection_name=name, data=[vector], anns_field="vector", search_params={"metric_type": "COSINE"}, filter=f'marker == "{marker}"', limit=1, output_fields=["id", "marker", "round"], consistency_level=consistency, timeout=timeout, ) hits = result[0] if result else [] return len(hits), hit…