Repository navigation
fix: isolate late GET response streams - #261
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryLate GETs that miss the subscription window now get a private broadcast, keeping each upstream response’s headers and body together.
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
left a comment
There was a problem hiding this comment.
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.
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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_LateGETsKeepUpstreamResponsesSeparateholds 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.BenchmarkHandleGetObjectLateSubscriberFallbackexercises 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, andgo 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_broadcastsnow counts keyed coalescing broadcasts plus these unkeyed late streams viasetActiveBroadcasts().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.