fix: re-raise exception in ingest_document so Celery retry mechanism fires (#561)#582
Open
ionfwsrijan wants to merge 10 commits into
Open
fix: re-raise exception in ingest_document so Celery retry mechanism fires (#561)#582ionfwsrijan wants to merge 10 commits into
ionfwsrijan wants to merge 10 commits into
Conversation
ac2e024 to
90a83c2
Compare
c50368b to
d6cca44
Compare
Contributor
Author
|
@param20h Please review this |
…parser) to account for module-level import
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.
Description
ingest_document()wraps its entire pipeline in atry/exceptblock. Theexcept Exceptionhandler logs the error, rolls back the DB session, marks the document as failed, and commits. However, the exception is completely consumed — never re-raised.Meanwhile, the Celery task
process_documentis decorated withautoretry_for=(Exception,),max_retries=3,acks_late=True— all designed to handle transient failures. But becauseingest_documentnever propagates an exception, none of them ever fire.Changes
backend/app/services/document_ingestion.pyraiseafter theexceptblock so the original exception propagates to Celery'sautoretry_forafter DB state is cleaned up (rollback, mark failed, commit).backend/app/tasks.pyingest_documentreturns, instead of hardcoding"completed". This ensures the task result accurately reflects success or failure.Impact
max_retries=3,default_retry_delay=30) is now functionalCloses #561