Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Fix: add missing db.session.close() to ensure proper session cleanup (#23122)
Yongtao Huangf17ca26b10f6
diff --git a/api/tasks/add_document_to_index_task.py b/api/tasks/add_document_to_index_task.pyindex a2105f8a9d9..c5ee4ce3f9e 100644--- a/api/tasks/add_document_to_index_task.py+++ b/api/tasks/add_document_to_index_task.py@@ -32,6 +32,7 @@ def add_document_to_index_task(dataset_document_id: str):returnif dataset_document.indexing_status != "completed":+ db.session.close()returnindexing_cache_key = f"document_{dataset_document.id}_indexing"@@ -112,3 +113,4 @@ def add_document_to_index_task(dataset_document_id: str):db.session.commit()finally:redis_client.delete(indexing_cache_key)+ db.session.close()diff --git a/api/tasks/create_segment_to_index_task.py b/api/tasks/create_segment_to_index_task.pyindex a8839ffc172..543a512851f 100644--- a/api/tasks/create_segment_to_index_task.py+++ b/api/tasks/create_segment_to_index_task.py@@ -31,6 +31,7 @@ def create_segment_to_index_task(segment_id: str, keywords: Optional[list[str]]returnif segment.status != "waiting":+ db.session.close()returnindexing_cache_key = f"segment_{segment.id}_indexing"diff --git a/api/tasks/document_indexing_sync_task.py b/api/tasks/document_indexing_sync_task.pyindex 56f330b9647..993b2ac4045 100644--- a/api/tasks/document_indexing_sync_task.py+++ b/api/tasks/document_indexing_sync_task.py@@ -113,3 +113,5 @@ def document_indexing_sync_task(dataset_id: str, document_id: str):logging.info(click.style(str(ex), fg="yellow"))except Exception:logging.exception("document_indexing_sync_task failed, document_id: %s", document_id)+ finally:+ db.session.close()