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
perf(dataset): fix N+1 database insert bottleneck in Notion sync (#39899)
Hassan Rady26b4798e880e
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.pyindex 2ac58e15911..0258ad7e304 100644--- a/api/services/dataset_service.py+++ b/api/services/dataset_service.py@@ -2402,13 +2402,14 @@ class DocumentService:truncated_page_name,batch,)+ document.id = str(uuid.uuid4())session.add(document)- session.flush()document_ids.append(document.id)documents.append(document)position += 1else:exist_document.pop(page.page_id)+ session.flush()# delete not selected documentsif len(exist_document) > 0:clean_notion_document_task.delay(list(exist_document.values()), dataset.id)diff --git a/api/tests/unit_tests/services/test_dataset_service_document.py b/api/tests/unit_tests/services/test_dataset_service_document.pyindex 26a3ac08d5f..e8e231936dc 100644--- a/api/tests/unit_tests/services/test_dataset_service_document.py+++ b/api/tests/unit_tests/services/test_dataset_service_document.py@@ -1022,6 +1022,7 @@ class TestDocumentServiceSaveDocumentWithDatasetId:patch.object(DocumentService, "build_document", return_value=created_document) as build_document,patch("services.dataset_service.clean_notion_document_task") as clean_task,patch("services.dataset_service.DocumentIndexingTaskProxy") as document_proxy_cls,+ patch("services.dataset_service.uuid.uuid4", return_value="doc-new"),):mock_redis.lock.return_value = _make_lock_context()session.scalars.return_value.all.return_value = [existing_keep, existing_remove]