Repository navigation
fix: wait for bulk-delete cache fences before responding - #238
Conversation
[Medium impact] The PR appears safe to merge; no new actionable issue was established. SummaryCache-enabled bulk
Reviews (7) · Last reviewed commit: "Merge origin/main into perfloop-pr-open-..." · Reviewed by Greptile |
This comment has been minimized.
This comment has been minimized.
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]>
929e5eb to
4412b33
Compare
HandleDeleteObjects now stages the captured DeleteResult until the post-success cache fence returns, so a stalled cache peer would hold the client's 2xx indefinitely: the fence ran under context.Background() with no deadline where main had run it after the response was already sent. Run the proxy-mode fence under a context derived from the request but detached from its cancellation (context.WithoutCancel, so a client that disconnects after upstream committed the delete does not abandon the fence) and bounded by bulkDeleteFenceTimeout (10s, matching the tiered converge's per-key bound). When the deadline fires the remaining per-key attempts fail fast, the captured upstream 2xx is still committed, and a Warn with the bucket and fenced key count records that the fence did not converge; stale metadata ages out via TTL as before. A timeout is never turned into a client-visible error. Add a synctest-driven test with a cache client that stalls every post-forward meta delete until its context ends: the response is released exactly at the fence deadline, is the byte-exact upstream 200, and the timeout warning carries the bucket and key count. Without the bound the test's bubble deadlocks. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6 (cherry picked from commit e470f5acef0931fcbda49b97d26819029dc8c6c9)
Resolve a test-file import conflict with #245 (both imports kept). Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
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 716199d. Configure here.
The tiered helper runs under its own per-key timeout, so a large tiered batch could hold the staged 2xx for N times that timeout regardless of the shared fence deadline. Check the shared deadline before each key in both modes and report the keys skipped in the timeout warning. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
README: keep the expanded PUT/DELETE bullet and #247's tombstone bullet. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NGTev5ePU5jHubGtdoUfK6
ovaistariq
left a comment
There was a problem hiding this comment.
Reviewed: bulk DeleteObjects now stages the upstream response and runs the post-success per-key fences before committing the 2xx, so a GET refilling the old object during the delete cannot stay servable after the client has its success. Fence bounded by a shared 10-second deadline in both modes with skipped keys counted in the warning; docs aligned.
|
🎉 This PR is included in version 1.22.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

Bulk
DeleteObjectscould send a complete 2xx response before TAG finished the second cache invalidation intended to remove a racing GET refill. The client could receive success while that stale refill remained available.For cache-enabled requests with a parsed nonempty key list, TAG captures upstream status, headers, and body before publishing them. On 2xx, existing per-key result rules select the invalidations; TAG commits after those attempts return. Keys whose requested entries all failed are skipped, and an unparseable result retains the conservative all-key fallback. Cache-disabled, malformed-request, and empty-key requests keep direct streaming. The README and cache/S3 docs describe this ordering.
TestBulkDeleteResponseWaitsForPostSuccessFencedrives the registered handler and transparent forwarder with a local upstream, concurrent GET, and held tombstone. It checks the complete response bytes and the GET after completion.TestBulkDeleteWithCacheDisabledKeepsStreamingverifies that the first response byte reaches the client before the upstream body finishes; it passes on the base and final source. The proxy testsTestHandleDeleteObjects_PartialFailureKeepsFailedKeyRefill,TestHandleDeleteObjects_MixedVersionSuccessReinvalidatesKey, andTestHandleDeleteObjects_VersionIdMismatchFailureKeepsRefillcover per-key results.TestHandleDeleteObjects_UnparseableResultInvalidatesAllAndPreservesResponse,TestHandleDeleteObjects_UpstreamFailurePreservesResponseAndRefill, andTestHandleDeleteObjects_IncompleteCapturePreservesPrefixAndInvalidatesKeycover byte-exact output and fallback behavior; they pass against the base production code and final source.TestDeleteObjectsResponseStagerCountsClientAcceptedByteschecks staged and direct output accounting.handlers/delete_objects_fence_benchmark_test.go::BenchmarkBulkDeleteResponseCompletionis a checked-in Gotesting.Bbenchmark, run with the repository's ordinarygo test -benchcommand. It measures the cached route through the registered handler and transparent forwarder, seeds a cache entry outside timing, reads a fixed-length 128 KiB-padded result to EOF, and waits for handler cleanup outside the timed span. Its in-memory cache and local upstream are a controlled fixture, not a production response-size distribution or latency estimate; no performance claim or threshold is made.The integration test
tests/integration/cache_test.go::TestCache_InvalidateOnDeleteObjectsdid not pass reliably here on either source revision because embedded-cache memberlist address discovery could not consistently find a private IP in this sandbox. Target CI should run it.This deliberately delays delivery while the upstream response is captured and, on 2xx, while invalidation attempts return. Proxy-mode invalidation has no cache-operation deadline; a nonreturning call can keep the response open. Returned backend failures retain the existing best-effort retry and may leave stale metadata until TTL. Buffer lifetime remains unmeasured.
The build, lint, vet, scoped handler/proxy unit and race tests, and benchmark smoke run passed locally. The default-profile S3 tests
s3tests/functional/test_s3.py::test_multi_object_deleteandtest_multi_objectv2_delete, plus SDK testsTestSDK_DeleteObjectsandTestSDK_DeleteObjects_WithCache, were not run because this environment has no AWS credentials or local TAG service; the repository's S3 workflow should run them with its configured Tigris service and credentials.This condition holds with this change and does not hold at
0126eeb4e2e093fa2b0ada2ee0a5464069f3a1e1:For a cache-enabled transparent POST /{bucket}?delete with one parsed key, successful cache operations, a fixed-length complete non-quiet 2xx DeleteResult reporting that key deleted, and a GET that refills its old object during the upstream delete, the client cannot finish the 2xx response until the key's post-success cache fence completes; a GET after that response cannot serve the stale refill..Generated by Perfloop.
Note
Medium Risk
Changes DeleteObjects response timing and cache consistency semantics for bulk deletes; incorrect fencing could delay clients up to 10s or briefly serve stale cache if invalidation stalls.
Overview
Fixes a read-after-write gap where cache-enabled
DeleteObjectscould finish streaming a successful 2xx while a racing GET had refilled stale data that the post-success invalidation had not yet cleared.For requests with a parsed nonempty key list and cache on, TAG now captures the upstream status, headers, and body via a response stager instead of writing to the client during
ForwardWithCapture. On upstream 2xx it runs the existing per-key post-success invalidation (success-only keys, conservative fallback when the XML is unparseable) under a shared 10s deadline withcontext.WithoutCancel, then commits the captured response. Cache-disabled, malformed, or empty-key requests still stream directly. If the fence does not finish in time, TAG logs a warning and still returns the upstream 2xx; skipped keys may stay stale until TTL. The forwarder defers outbound byte metrics until staged responses are committed.Docs in README,
cache-control.md, ands3-compatibility.mddescribe the new ordering. Tests and a benchmark cover fence ordering, partial failures, upstream errors, stalled cache peers, and metric accounting.Reviewed by Cursor Bugbot for commit 698d9e0. Bugbot is set up for automated code reviews on this repo. Configure here.