mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-08-16 12:40:43 +00:00
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:
parent
95c06f1bde
commit
73452e63fa
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user