Release semphore before merge stage

This commit is contained in:
yangdx 2025-07-09 09:24:44 +08:00
parent 56d43de58a
commit cb3bfc0e5b
2 changed files with 58 additions and 59 deletions

View file

@ -1069,9 +1069,9 @@ class LightRAG:
} }
) )
# Semphore is NOT released here, because the merge_nodes_and_edges function is highly concurrent # Semphore is released here
# and more importantly, it is the bottleneck and needs to be resource controlled in massively # Concurrency is controlled by graph db lock for individual entities and relationships
# parallel insertions
if file_extraction_stage_ok: if file_extraction_stage_ok:
try: try:

View file

@ -36,6 +36,7 @@ from .base import (
) )
from .prompt import PROMPTS from .prompt import PROMPTS
from .constants import GRAPH_FIELD_SEP from .constants import GRAPH_FIELD_SEP
from .kg.shared_storage import get_graph_db_lock_keyed
import time import time
from dotenv import load_dotenv from dotenv import load_dotenv
@ -1121,8 +1122,6 @@ async def merge_nodes_and_edges(
pipeline_status_lock: Lock for pipeline status pipeline_status_lock: Lock for pipeline status
llm_response_cache: LLM response cache llm_response_cache: LLM response cache
""" """
# Get lock manager from shared storage
from .kg.shared_storage import get_graph_db_lock_keyed
# Collect all nodes and edges from all chunks # Collect all nodes and edges from all chunks