Repository navigation
download_file: publish downloads atomically - #1561
Open
martinpitt wants to merge 2 commits into
Open
martinpitt wants to merge 2 commits into
martinpitt wants to merge 2 commits into
Conversation
Commit 19c7323 made the immediate materializer replace a write action's output atomic. download_file has the same race and needs the same mechanics. Move that machinery out of the immediate materializer into `buck2_execute`, where the download code can use it too.
A download with a declared checksum and size writes straight to its content-based path, which has no configuration component. A target analyzed under several configurations downloads that path once per configuration, and each download removed what was there and wrote the file in place. A consumer of the download that finished first could find the file missing, empty or half written. Commit 19c7323 fixed this kind of race for write actions. Do the same for downloads, using the same `atomic_publish` machinery. A download that fails its checksum now also leaves nothing behind.
This was referenced Oct 12, 2026
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D124703713. (Because this pull request was imported automatically, there will not be any future comments.) |
Collaborator
|
@lf- another CBP race for your tally |
Collaborator
|
bloody hell. maybe i should dispatch an agent to write a tla+ formalization of what it's doing and then find all the bugs in it. |
This branch has not been deployed
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.
A download with a declared checksum and size writes straight to its
content-based path, which has no configuration component. A target
analyzed under several configurations downloads that path once per
configuration, and each download removed what was there and wrote the
file in place. A consumer of the download that finished first could find
the file missing, empty or half written.
Commit 19c7323 fixed this kind of race for write actions. Do the same
for downloads, using the same
atomic_publishmachinery. A downloadthat fails its checksum now also leaves nothing behind.
We ran into this in amutable-systems/tine#292. We recently updated to a new buck which enabled the content-addressable buck-out/, and that exhibited the bug. Of course we shouldn't download a file three times in the first place (and I fixed that in amutable-systems/tine#295) but still, if it happens a buck build shouldn't crash on a half-written tar file.