Repository navigation
fix(id/web): make upload-name claiming atomic (#2363) - #3425
Merged
Merged
Conversation
Hold an AppState upload-name mutex across uniquify-resolve, the tags().set claim, and the filename-keyed metadata writes in upload_handler, so two concurrent same-name different-bytes uploads can no longer both resolve to the same free name and silently un-name the first (#1549 concurrent case). Sequential semantics unchanged. Adds a regression test that interleaves two same-name uploads at the resolve/set boundary (via the same lock) and asserts distinct stored names, per-blob responses, listing/resolvability, and metadata describing the blob each name resolves to.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 27 seconds. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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. |
3 tasks
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.
Closes #2363. Queue task 5250 (follow-up from triage task 3521, verdict CONFIRMED).
Problem
upload_handlerresolved the stored name viauniquify_upload_name(get-only check) and claimed it with a separate awaited unconditionaltags().set— two concurrent same-name different-bytes uploads could both resolve to the same free name, and the later set silently un-named the first (the #1549 failure mode, concurrent case). Filename-keyed metadata written after the tag set could also describe the losing upload.Fix
AppStategains anupload_name_lock: Arc<Mutex<()>>(shared across state clones).upload_handlerholds that lock across uniquify-resolve, thetags().setclaim, and all filename-keyed metadata writes, making resolve+claim atomic from the handler's perspective.Scope note (stated in code): the lock coordinates handlers sharing one AppState; independent states/processes and non-upload tag writers do not participate — matching the packet scope.
Tests
concurrent_uploads_keep_names_and_metadata_consistent: holds the resolve/claim lock while two same-name (image.png) different-bytes uploads start, asserts neither completes its claim early, then both succeed under distinct stored names, each response naming its own blob, both listed/resolvable with matching bytes, and filename-keyed metadata (content-type, created) consistent with the blob each name resolves to.Verification: targeted
cargo test --features web --lib upload_router_testson the laptop — result posted on #2363 when it lands.Need help on this PR? Tag
@codesmith-botwith what you need.