Repository navigation
fix: release cache relay slots after write failures - #264
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
[High impact] The PR appears safe to merge; no actionable new issue or repository-rule violation was found. SummaryThis PR releases cache-populate slots after returned write failures without changing the successful origin response.
The ancestry and merge-base checks passed. Review of new behavior used the changes since Reviews (2) · Last reviewed commit: "docs: document cache-write recovery" · Reviewed by Greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fd85dea. Configure here.
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
|
Addressed in The cache deadline path is addressed in this update. The relay now closes the pipe with the deadline error instead of clean EOF, and the full-GET test verifies that a partial cache body cannot become visible. |
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

A whole-body cache write can return before the relay has consumed its pipe. The GET must still send the complete successful origin response, but a failed cache write can leave relay goroutines and a populate reservation alive. The relay now closes the cache-side pipe with the returned store error, cancels the detached context, and returns queued and listener buffers before releasing the reservation. Deadline errors reach the cache pipe as errors rather than clean EOF, preventing incomplete whole-body entries from being published. Block-mode writes retain their drain-on-error path. The README and architecture guide describe returned-error recovery and the limit when a store call never returns. No public API or configuration changed.
TestCacheableFullGet_StoreFailureReleasesRelayAndReservationinjects failures before reading, after seven bytes, and after EOF through full GETs. On base628616f, the before-read and partial-read cases fail while the after-EOF control passes. On intermediate repairfd85deaand final revision264d0ed, all three pass. It checks the origin status, headers and bytes, terminal error observation, absent failed metadata, released count and byte reservations, and a later cache hit.TestCacheableFullGet_DeadlineDoesNotPublishPartialBody verifies that a cache deadline cannot publish a truncated whole-body entry while the GET returns the complete origin response.
raw_filesubtest (128 KiB)inlinesubtest (40 KiB)628616ffd85dea264d0edThe deadline test fills the 64-entry relay queue and uses Go virtual time with a cache-client double modeling the pinned local-CAS partial-read path; it resumes the store after the deadline. It does not promise termination if a store call never returns. Cache-focused embedded-store integration tests exercise normal whole-body and block-mode writes.
This condition holds with this change and does not hold at
628616fd9e19fac473837eb45eb46115e3d33313:For cacheable sub-block full-GET misses in non-tiered mode, once the whole-body cache writer has returned an error before reading, after a partial read, or after EOF and the successful client request has completed, no cache relay or populate reservation may remain live. The original cache error must be observed, no failed metadata may be visible, and a later healthy GET must populate; the first GET must preserve the origin status, headers, and bytes..make test-proxy, the cache-focused embedded-store integration tests,make build,make lint-ci, and the affected tests under the race detector pass. The unfilteredmake testsuite remains target-CI work. The comparison harness is not included in the pull request, and injected failures do not measure their production frequency.Generated by Perfloop.
Note
Medium Risk
Changes cache-miss populate lifecycle and error propagation in a hot path; incorrect teardown could leak memory or publish bad cache entries, but behavior is heavily regression-tested.
Overview
Fixes whole-object cache populate teardown when the store write fails or hits its deadline, so clients still get the full successful origin GET while relay goroutines, pooled buffers, and populate reservations are released reliably.
On cache write error, the relay now closes the pipe read end with the store error and cancels the populate context to unblock writers stuck on a partial read. Early exit (deadline or upstream error) drains the chunk queue and synchronously releases remaining listener buffers before the slot is freed; relay deadlines close the pipe with an error instead of a clean EOF so truncated bodies cannot publish metadata. README and architecture docs note best-effort population and that a store call that never returns has no completion guarantee.
Adds integration-style tests for injected
PutStreamfailures (before read, partial read, after EOF) and for deadline-driven partial reads (inline and raw-file paths).Reviewed by Cursor Bugbot for commit 264d0ed. Bugbot is set up for automated code reviews on this repo. Configure here.