fix: surface aborted partial cache writers as errors, not clean EOF - #949
Open
stareezy-1 wants to merge 1 commit into
Open
fix: surface aborted partial cache writers as errors, not clean EOF#949stareezy-1 wants to merge 1 commit into
stareezy-1 wants to merge 1 commit into
Conversation
A streaming partial-cache reader treated the writer-side sender dropping as clean end-of-body, even though the storage contract says a miss handler dropped without finish() is a failed write. A cancelled writer therefore made a partial response look complete (HttpTask::Done) after only a prefix of the upstream body. PartialHit::read() now returns an error when the sender drops while the state is still Partial. MemMissHandler::finish() sends the Complete marker (borrowing the watch value before send_replace, which takes the internal write lock) so a successful admission still yields a clean EOF even when the final write_body did not set eof=true.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #932
Problem
A streaming partial-cache reader treats the writer-side sender dropping as clean end-of-body:
But the storage contract says a miss handler dropped without
finish()is a failed write. When a cache-miss writer is cancelled before EOF and beforefinish(), the partial reader reportsOk(None), which the proxy converts toHttpTask::Done— the client receives a truncated response that appears complete.Reproduction: start a streaming write on
MemCache, read the partial body, then drop the writer withoutfinish(). The reader returnsOk(None)(clean EOF) instead of an error.Fix
PartialHit::read()returns an error when the sender drops while the state is stillPartial— the writer never reached EOF, so the admission failed.MemMissHandler::finish()sends theCompletemarker before consuming the handler, so a successful admission still yields a clean EOF even when the finalwrite_bodyhadeof=false. The watch value is copied out beforesend_replace(which takes the watch's internal write lock) to avoid a self-deadlock with the borrowRef.After the fix, the reader state machine is unambiguous:
Completestate = real EOF; sender drop whilePartial= aborted writer (error → failed response, not truncated success).Tests
test_partial_reader_errors_on_aborted_writerinmemory.rs:finish()/EOFread_body()returnsErrtest_write_while_read(existing)finish()after non-EOF writes still yields clean EOFFull crate suite passes (145 tests),
cargo fmt --checkclean, clippy clean for the touched file.