Improve thread safety for relationship rebuilding
- Sort src and tgt for consistent lock keys - Maintain order-independent locking
This commit is contained in:
parent
05bc5cfb64
commit
6e1657a771
1 changed files with 5 additions and 1 deletions
|
|
@ -429,8 +429,12 @@ async def _rebuild_knowledge_from_chunks(
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
workspace = global_config.get("workspace", "")
|
workspace = global_config.get("workspace", "")
|
||||||
namespace = f"{workspace}:GraphDB" if workspace else "GraphDB"
|
namespace = f"{workspace}:GraphDB" if workspace else "GraphDB"
|
||||||
|
# Sort src and tgt to ensure order-independent lock key generation
|
||||||
|
sorted_key_parts = sorted([src, tgt])
|
||||||
async with get_storage_keyed_lock(
|
async with get_storage_keyed_lock(
|
||||||
f"{src}-{tgt}", namespace=namespace, enable_logging=False
|
f"{sorted_key_parts[0]}-{sorted_key_parts[1]}",
|
||||||
|
namespace=namespace,
|
||||||
|
enable_logging=False,
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
await _rebuild_single_relationship(
|
await _rebuild_single_relationship(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue