[FIX] Surface a failed document upload instead of hanging S3 staging - #522
Open
noel-improv wants to merge 2 commits into
Open
[FIX] Surface a failed document upload instead of hanging S3 staging#522noel-improv wants to merge 2 commits into
noel-improv wants to merge 2 commits into
Conversation
noel-improv
marked this pull request as ready for review
September 8, 2026 18:52
…ng staging _upload_batch polls until it has seen one item per submitted document, but three except blocks could each leave that count unreachable, so a failed upload became a run that never returned. What hid it was _upload_doc swallowing its own S3 error and returning None: the count advanced, and the document was yielded and counted as staged. The two are a pair, so removing the swallow alone turns a silent success into a hang. Every submitted document now puts exactly one item on the queue, a failure marker when the upload raised. The publisher puts its count in a finally so a producer that dies still releases the consumer, the consumer also breaks out when its producer is gone, and the first failure is raised once the batch drains. A document that failed to write is no longer yielded. Confirmed against a real boto3 client: a ClientError from S3 propagates, nothing is reported as staged, and the call returns.
noel-improv
force-pushed
the
fix/s3-staging-upload-failure
branch
from
September 8, 2026 19:56
7571fda to
d2554c2
Compare
…alled the queue The class carried a second _task_complete_callback that released the semaphore without putting anything on the queue. Nothing has ever wired it up, and connecting it would reproduce the staging hang this change fixes, on every document rather than only on a failed upload.
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
A failed document upload during S3 staging either hangs the run with no exception, or is reported as successfully staged. Both are silent, so a failed upload looks like a slow run or a clean one.
_upload_batchpolls until it has seen one item per submitted document and treatsqueue.Emptyas "keep waiting", never checking whether its producer is still alive. Threeexcept Exception: logblocks could each leave that count unreachable.What stops it firing today is
_upload_docswallowing its own S3 exception and returningNone. The callback puts thatNone, the count advances, and the document is yielded and counted in the "Finished writing N source documents" total. The two defects are a pair: removing the swallow alone turns a silent success into a hang.Changes
One invariant — every submitted document puts exactly one item on the queue.
_get_callback_fnalways puts, a failure marker when the upload raised, and releases the semaphore in afinally._submit_proxyreports whether it submitted, so the publisher counts only what the consumer will see._doc_publisherputs its count in afinallyand catchesBaseException, so a producer that dies still releases the consumer._upload_batchbreaks out when the queue is empty and the producer is gone, and raises the first failure once the batch drains._upload_docstops swallowing.The queue poll drops from 60s to 1s. It paces the liveness check rather than the work, so a dead producer is noticed in about a second instead of a minute.
Problem
Related issue (if any): #
Introduced in
4b8743c0("Improved batch extract and S3BasedDocs for large ingests") rather than by a targeted change. #418 is the same symptom in the same path from a different cause and is already fixed.Testing
pytest) — 2,112 intests/unitFive tests, red before green, covering a failing document mid-batch, a dead producer, and the all-succeed path. No test previously failed a document mid-batch, which is the gap that hid this.
Checked against a real boto3 S3 client rather than a mock:
put_objectreturns a genuineClientError, the error propagates to the caller, no document is reported as staged, and the call returns instead of hanging.One pre-existing failure is unrelated and reproduces on a clean tree:
test_integ_dependency_compatibility.pyerrors withNo module named pipin this venv.Checklist
A caller that relied on a failed upload being silently skipped will now see the exception. That is the intended change.