You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No guard against deleting a dataset while its documents are still indexing — this request.
DatasetService.delete_dataset (api/services/dataset_service.py, ~L1308) sends the dataset_was_deleted signal and does db.session.delete(dataset) immediately, with no check for or cancellation of in-flight indexing. When a dataset is deleted mid-indexing, the running pipeline keeps executing and fails repeatedly with KnowledgeIndexNodeError: Dataset <id> not found. (core/rag/index_processor/index_processor.pyindex_and_clean), and it can keep writing rows that race with the cleanup task — the root cause behind the orphaned data in #38518. Even with #38519 making cleanup robust, avoiding the race in the first place is the correct defensive posture.
2. Describe the feature you'd like to see
Before deleting a dataset, pause and await any in-flight indexing for its documents, then delete.
A concrete shape (suggested on #38518): reuse the existing per-document pause mechanism — Document.is_paused (set e.g. in controllers/console/datasets/datasets_document.py) which makes indexing_runner raise DocumentIsPausedError at its stage checkpoints. delete_dataset could:
Find all documents of the dataset in an active indexing state (IndexingStatusWAITING / PARSING / CLEANING / SPLITTING / INDEXING, see models/enums.py).
Set their pause flag (Redis + DB) and wait for the running tasks to acknowledge/stop at the next checkpoint (with a bounded timeout).
Proceed with deletion + cleanup once no document is actively indexing.
This closes the race without having to revoke Celery tasks directly. An alternative (simpler but less friendly) is to reject deletion with a clear error while indexing is active, letting the user stop/finish it first.
3. How will this feature improve your workflow?
Deleting a knowledge base while it is still indexing (easy to do on large ingests) no longer races the cleanup and leaves tens of GB of orphaned document_segments / child_chunks / embedding_vector_index_* behind — which is exactly what we hit in production (#38518).
Self Checks
1. Is this request related to a challenge you're experiencing?
Follow-up to #38518. That issue has two halves:
DatasetService.delete_dataset(api/services/dataset_service.py, ~L1308) sends thedataset_was_deletedsignal and doesdb.session.delete(dataset)immediately, with no check for or cancellation of in-flight indexing. When a dataset is deleted mid-indexing, the running pipeline keeps executing and fails repeatedly withKnowledgeIndexNodeError: Dataset <id> not found.(core/rag/index_processor/index_processor.pyindex_and_clean), and it can keep writing rows that race with the cleanup task — the root cause behind the orphaned data in #38518. Even with #38519 making cleanup robust, avoiding the race in the first place is the correct defensive posture.2. Describe the feature you'd like to see
Before deleting a dataset, pause and await any in-flight indexing for its documents, then delete.
A concrete shape (suggested on #38518): reuse the existing per-document pause mechanism —
Document.is_paused(set e.g. incontrollers/console/datasets/datasets_document.py) which makesindexing_runnerraiseDocumentIsPausedErrorat its stage checkpoints.delete_datasetcould:IndexingStatusWAITING/PARSING/CLEANING/SPLITTING/INDEXING, seemodels/enums.py).This closes the race without having to revoke Celery tasks directly. An alternative (simpler but less friendly) is to reject deletion with a clear error while indexing is active, letting the user stop/finish it first.
3. How will this feature improve your workflow?
Deleting a knowledge base while it is still indexing (easy to do on large ingests) no longer races the cleanup and leaves tens of GB of orphaned
document_segments/child_chunks/embedding_vector_index_*behind — which is exactly what we hit in production (#38518).Related
_delete_recordsduring dataset deletion)