Skip to content

fix: unblock full GETs on pre-header upstream failures - #260

Merged
ovaistariq merged 1 commit into
mainfrom
perfloop-pr-open-qh82wv6t35
Oct 21, 2026
Merged

ovaistariq merged 1 commit into
mainfrom
perfloop-pr-open-qh82wv6t35

Conversation

@perfloop

@perfloop perfloop Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Full-object GETs could wait after the upstream transport had already failed before response headers. The broadcaster recorded the error on its chunk stream, but header waiters remained blocked on a separate signal. Completion now publishes the terminal pre-header error through the existing header-wait result and replays an unstreamed completion to late listeners before manager removal.

Successful header readiness remains distinct from failure. Empty responses still finish normally, cancellation before headers remains effective, and a response already committed cannot be replaced with an S3 error document. The handler reaches its existing S3 InternalError mapping for a live uncommitted failure. The README and S3 compatibility guide describe the behavior, and the architecture table reflects the existing HTTP 500 mapping.

This condition holds with this change and does not hold at 628616fd9e19fac473837eb45eb46115e3d33313: For a non-tiered full-object GET that has entered the broadcast path, when a non-context upstream transport error occurs before response headers and two callers share the broadcast with live request contexts, both service calls return the same original error, the handler returns its existing uncommitted S3 InternalError response, the initiating call removes the broadcast, and no cache populate starts or writes data..

TestPreHeaderTransportErrorUnblocksCoalescedGetters reproduces the base live-context hang and passes on the final source; it checks error identity, one shared fetch, manager removal, and no cache writes. TestGetObjectPreHeaderTransportFailureUsesS3ErrorResponse reproduces the base handler wait and passes on the final source, verifying the real router's XML error response. TestBroadcasterCompletionBeforeHeadersWakesExistingAndLateListeners fails on the base and passes on the final source, verifying error delivery to both registered waiters and a terminal late subscriber.

The added preservation tests cover separate cases:

  • TestBroadcasterCancellationBeforePreHeaderCompletion verifies cancellation still wins when it precedes a pre-header failure; it passes on the base and final sources.
  • TestWriteChunksToResponse_CompletedEmptyBroadcastWithLateListener verifies a late subscriber receives an empty 200 response; on the base it blocks because its chunk channel is left open, and on the final source it returns the headers with no body.
  • TestWriteChunksToResponse_CompletedHeaderErrorWithLateListener verifies a post-header body error reaches a late listener without committing a success response; on the base it blocks on the open chunk channel, and on the final source it returns the error before commitment.

Existing normal-streaming, partial-data, cancellation, and successful-header-precedence tests pass on the final source. The scoped proxy and handler tests passed: go test -count=1 ./proxy/... ./handlers/.... Their race-enabled run passed: go test -race -count=1 ./proxy/... ./handlers/.... Package vet passed: go vet ./proxy/... ./handlers/.... Repository lint and application build passed: make lint-ci and make build. The comparative fault-injection harness used for the source comparison is not included in this PR; the native Go regression tests are. Only affected package suites ran locally; the broader repository suite remains target-CI work. Production failure frequency and failure latency remain unmeasured.


Generated by Perfloop.


Note

Medium Risk
Touches request-coalescing and error-path behavior on cache-miss GETs; incorrect signaling could still hang clients or mis-map errors, but changes are narrowly scoped with broad tests.

Overview
Fixes a hang where coalesced full-object GETs could block forever when upstream failed before response headers were sent: the broadcast recorded the error on the chunk stream but WaitForHeaders never woke.

The broadcaster now signals pre-header completion via headerErr / headerCh, replays the terminal result to late subscribers on an already-finished (non-streaming) broadcast, and keeps request cancellation ahead of that error when the context is already dead. Coalesced waiters return the same upstream error without cache writes; the HTTP layer still maps live uncommitted failures to S3 InternalError (HTTP 500), with no X-Cache on that path.

Docs (README, architecture, S3 compatibility) describe this coalescing failure behavior and document Uncommitted upstream error as HTTP 500 instead of treating generic upstream errors as 502. Regression tests cover broadcaster, proxy coalescing, handler XML errors, and late-listener writeChunksToResponse cases.

Reviewed by Cursor Bugbot for commit 76d0bac. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no actionable issues were found.

Summary

Fixes full-object GETs waiting indefinitely when upstream fails before sending headers.

  • Live GETs receive upstream errors before response headers arrive.
  • Late GET listeners receive the result of a completed broadcast.

No actionable issues found. Tests were reviewed but not run during this review.

Reviews (1) · Last reviewed commit: "fix: unblock full GETs on pre-header ups..." · Reviewed by Greptile

@ovaistariq
ovaistariq merged commit be0d9dd into main Oct 21, 2026
10 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-qh82wv6t35 branch October 21, 2026 05:39
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 21, 2026
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.22.3 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants