fix: reconcile orphaned parsing tasks after system crash/reboot#13176
Open
timon0305 wants to merge 1 commit intoinfiniflow:mainfrom
Open
fix: reconcile orphaned parsing tasks after system crash/reboot#13176timon0305 wants to merge 1 commit intoinfiniflow:mainfrom
timon0305 wants to merge 1 commit intoinfiniflow:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13171
When the system crashes or reboots during document parsing, Redis loses queued tasks while MySQL retains the "Parsing" state (
run='1',progress > 0). This causes documents to appear stuck in "Parsing" indefinitely with no backend processing.This PR adds startup reconciliation logic to detect and re-queue orphaned tasks:
DocumentService.get_orphaned_parsing_docs()- Queries documents stuck in Parsing state (run=RUNNING, 0 < progress < 1)TaskService.get_incomplete_tasks_by_doc_ids()- Retrieves incomplete tasks for orphaned documentsrequeue_orphaned_tasks()- Reconciliation function that re-queues incomplete tasks into Redis, or marks documents as failed if no tasks remaintask_executor.py- Uses a Redis distributed lock so only one worker runs reconciliation, preventing duplicate re-queuingDocuments with no remaining incomplete tasks are marked as FAIL with an explanatory message rather than left in a permanently stuck state.
Test plan