Add async lock for atomic graph database operations
• Introduced graph_db_lock mechanism • Ensured atomic node/edge merge and insert operation
This commit is contained in:
@@ -519,6 +519,11 @@ async def extract_entities(
|
|||||||
for k, v in m_edges.items():
|
for k, v in m_edges.items():
|
||||||
maybe_edges[tuple(sorted(k))].extend(v)
|
maybe_edges[tuple(sorted(k))].extend(v)
|
||||||
|
|
||||||
|
from .kg.shared_storage import get_graph_db_lock
|
||||||
|
graph_db_lock = get_graph_db_lock(enable_logging = True)
|
||||||
|
|
||||||
|
# Ensure that nodes and edges are merged and upserted atomically
|
||||||
|
async with graph_db_lock:
|
||||||
all_entities_data = await asyncio.gather(
|
all_entities_data = await asyncio.gather(
|
||||||
*[
|
*[
|
||||||
_merge_nodes_then_upsert(k, v, knowledge_graph_inst, global_config)
|
_merge_nodes_then_upsert(k, v, knowledge_graph_inst, global_config)
|
||||||
|
Reference in New Issue
Block a user