Fix retry_document_indexing_task exiting early on single document failure#37552
Open
ifer47 wants to merge 2 commits into
Open
Fix retry_document_indexing_task exiting early on single document failure#37552ifer47 wants to merge 2 commits into
ifer47 wants to merge 2 commits into
Conversation
In retry_document_indexing_task, two bugs caused the task to abort processing all remaining documents when a single document encountered an issue: 1. When a document was not found in the database, `return` was used instead of `continue`, causing the entire task to exit and skip all subsequent documents in the list. 2. When billing limit was exceeded, only the current document was marked as ERROR and had its Redis cache key cleaned up. All remaining documents were left with stale retry cache keys in Redis (potentially blocking future retries) and were not updated to reflect the error state. Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
Contributor
Pyrefly Type Coverage
|
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
returntocontinuewhen a document is not found, so remaining documents in the batch are still processedBug Details
Bug 1:
returninstead ofcontinueIn the
for document_id in document_idsloop, whensession.scalar(...)returnsNone(document not found), the code usedreturnwhich exits the entire task function. This silently skips all subsequent documents that may be perfectly valid.Bug 2: Incomplete cleanup on billing limit
When the billing limit check raises, only the current document was marked as
IndexingStatus.ERRORand had itsdocument_{id}_is_retriedRedis key deleted. All remaining documents in the list:Since all documents belong to the same tenant and the billing limit applies to the tenant, no remaining document can succeed either. They should all be marked as ERROR and have their cache keys cleaned up.
Test plan
🤖 Generated with Claude Code Best