Repository navigation
fix(storage): stop new uploads from overwriting a live entry's data - #321
Merged
Merged
Conversation
An upload's folder was named after its random ten-digit id, and nothing checked that no live storage location used that folder. With many live entries a new upload could draw a live folder's number and write its Parts over that entry's data, so one key served another key's bytes. Name each upload's folder with a UUID instead. The id stays the same random number for the upload URL. Readers take the folder from the stored folderName, so existing numeric folders keep working. Closes #320 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
A new upload could overwrite another cache entry's data, and that key then served the wrong bytes without any error. The folder for an upload's Parts was named after its random 10-digit upload id, and nothing checked whether a live storage location already used that folder. A cache with ~190k entries and ~125k uploads a day hits about two of these collisions each day (#320).
Now every upload gets a UUID folder. The upload id stays the same random number for the upload URL. Readers take the folder from the stored
folderName, so existing numeric folders keep working and no migration is needed.✅ Verification
New test
an_upload_never_writes_into_a_live_folder_named_after_its_id:new uploadTwo cleanup tests that assumed the folder name equals the upload id now read the upload's stored folder.
cargo +nightly fmt --checkandcargo clippy --all-targets --locked: cleancargo test: 84/84 on SQLite + filesystem and on Postgres + S3🔍 Reviews
Each review ran on Opus 5.5, GPT 6.1 Sol and Gemini 4 Neon.
🔗 Issues
Closes #320
💥 Merge danger
Door: two-way. Older versions also read the folder from the stored
folderName, so a rollback still serves entries in UUID folders.Blast Radius: uploads. Only how new upload folders are named changes. Hot paths make no extra round trips.
Entries already corrupted by a collision stay corrupted. This fix stops new collisions only, and the server keeps no checksum it could use to find the bad entries. Deployments with many entries can clear their cache to be sure.
🤖 Generated with Claude Code