Repository navigation
fix(blobstore): stop a local write when its request is cancelled - #3394
Merged
Merged
Conversation
A local-storage write that its caller cancelled, for example when a request deadline passed, kept writing and syncing its temporary file and then published it under the key. A write or sync stalled on the disk now fails once the context ends, the temporary file is removed, and nothing is published after the caller gave up. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Contributor
4 tasks done
4 tasks done
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.
Problem
Related issue: N/A
Validation tasks: none
The local filesystem blob store kept writing after the caller's context was
cancelled. A write stuck on a slow body or a slow disk could finish and
publish its file after the request that started it had given up, and a write
cancelled mid-stream could report "file already closed" instead of a context
error. This change makes cancellation stop the write, never publish after
cancellation, and report the cancellation.
Approach
publishcloses the temporary file when the context ends and keeps thatguard armed through the final
Sync. It checks the context again just beforethe rename or link that publishes the file. When cancellation closed the file,
the error is the context's cause, wrapping any write or sync error. The
deferred cleanup removes the temporary file as before. Every
PutStreamandCreateExclusivecaller gets this; the S3 store already stopped oncancellation.
Validation
go vet, and changed-line lint: pass.temporary file left) passes, including 1,000 repeated runs under
-race.blobstoretests pass.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3394/
Risks
A single write or sync call already blocked in the kernel, such as on a hung
network mount, cannot be interrupted from Go; closing the file makes the next
call fail and nothing is published. Callers that passed a context ending
right after the body was read now get an error instead of a published file;
none was found among existing callers.
Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Fix
Filesystem.publishto stop writing and skip publish on cancellationAdds a context cancellation callback in filesystem.go that closes the temporary file during a write or sync.
publishthen returns the context cause, and after syncing it checks the context again before renaming the temporary file into place.TestFilesystemCanceledStreamIsNeverPublishedwith acancelingReaderthat cancels mid-stream; the test verifies the error iscontext.Canceled,StatreturnsErrNotFound, and the uploads directory stays emptyMacroscope summarized aa68209.