Skip to content

fix: isolate late GET response streams - #261

Merged
ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-cnsgfqrazw
Oct 21, 2026
Merged

ovaistariq merged 3 commits into
mainfrom
perfloop-pr-open-cnsgfqrazw

Conversation

@perfloop

@perfloop perfloop Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Late GETs that miss the subscription window now receive private broadcasters, so an upstream response's headers and body chunks stay together. These unkeyed streams are included in tag_active_broadcasts.

TestHandleGetObject_LateGETsKeepUpstreamResponsesSeparate holds two callers after they obtain the same broadcaster, starts the original stream, then releases two distinct late upstream bodies before either producer finishes. It checks status, upstream ID, ETag, content type, Content-Length and complete body in cache-disabled and cache-enabled runs. The test reproduces mixed bodies without the fix and passes with it. BenchmarkHandleGetObjectLateSubscriberFallback exercises the fallback without claiming a speedup.

The README and architecture guide now state that callers which subscribe before the first body chunk share one upstream fetch; a later GET starts a separate broadcast and fetch. The proxy and handler unit suites pass normally and under the race detector. TestCache_HitWithMetadata, make build, make lint-ci, and go vet ./proxy/... ./handlers/... pass. A small source-comparison wrapper is kept outside the PR; the Go regression test and native benchmark are included.

This condition holds with this change and does not hold at d3fd04795091a1e5ef37c1895b35f2691ba7f58e: For cache-disabled and cache-enabled full-object GETs, when two callers obtain the same unstreamed broadcaster and subscribe only after the original response has broadcast its first chunk, and two distinct successful late upstream responses each deliver one nonempty body chunk that is broadcast before either late producer completes, each late client response has status, upstream ID, ETag, content type, Content-Length, and complete body matching exactly one late upstream response..

The forced schedule establishes the response-identity property for that ordering. Production frequency remains unknown.


Generated by Perfloop.


Note

Medium Risk
Changes concurrent GET miss/coalescing behavior on a hot path; incorrect handling could corrupt client responses, but the fix is narrowly scoped with targeted tests.

Overview
Fixes late full-object GET handling when a client misses the coalescing subscribe window (after the first upstream body chunk). Those requests no longer join a shared ":late" manager entry; each gets a private broadcaster and its own upstream fetch so headers and body chunks stay matched.

tag_active_broadcasts now counts keyed coalescing broadcasts plus these unkeyed late streams via setActiveBroadcasts().

Docs (README, architecture) clarify that coalescing applies only before streaming starts; later GETs cannot join and trigger separate fetches.

Adds regression coverage (TestHandleGetObject_LateGETsKeepUpstreamResponsesSeparate) and a benchmark for the late-subscriber fallback path.

Reviewed by Cursor Bugbot for commit aaa0cbc. 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

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

Summary

Late GETs that miss the subscription window now get a private broadcast, keeping each upstream response’s headers and body together.

  • Late GETs each keep their upstream response in a private broadcast.

No actionable issues were found. This review used source inspection; tests were not run.

Reviews (1) · Last reviewed commit: "docs: clarify late GET coalescing" · Reviewed by Greptile

@ovaistariq ovaistariq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against main 628616f: when Subscribe returns nil, a second late caller could reuse the same ':late' broadcaster and both ran fetchAndBroadcast into one listener set, interleaving bodies. A private broadcaster per late fetch is the correct, minimal fix; the scheduled test reproduces the mixed-body outcome on base.

@ovaistariq
ovaistariq merged commit b3b12ca into main Oct 21, 2026
10 checks passed
@ovaistariq
ovaistariq deleted the perfloop-pr-open-cnsgfqrazw branch October 21, 2026 05:38
@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