atomicallyWriteTo: remove temporary file prior to creating it#19243
Closed
EdSchouten wants to merge 1 commit intobazelbuild:masterfrom
Closed
atomicallyWriteTo: remove temporary file prior to creating it#19243EdSchouten wants to merge 1 commit intobazelbuild:masterfrom
EdSchouten wants to merge 1 commit intobazelbuild:masterfrom
Conversation
src/main/java/com/google/devtools/build/lib/actions/cache/VirtualActionInput.java
Outdated
Show resolved
Hide resolved
| @@ -67,6 +67,11 @@ public byte[] atomicallyWriteRelativeTo(Path execRoot, String uniqueSuffix) thro | |||
| protected byte[] atomicallyWriteTo(Path outputPath, String uniqueSuffix) throws IOException { | |||
| Path tmpPath = outputPath.getFileSystem().getPath(outputPath.getPathString() + uniqueSuffix); | |||
Contributor
There was a problem hiding this comment.
The fact that you're seeing this problem (and we've seen some similar ones) just goes to show that the uniqueSuffix is insufficiently unique. We should rather add something truly unique here and have the uniqueSuffix just serve to indicate what it's used for (which is most of the usage I see today).
Contributor
Author
There was a problem hiding this comment.
Actually using a deterministic suffix here is actually not that bad. It means that if the process is repeated, any stale temporary files get cleaned up automatically, right?
This change is the same in spirit to bazelbuild#19241. When using Bazel in combination with bb_clientd, bb_clientd may restore a copy of bazel-out/ from a snapshot. Files restored from the snapshot are not mutable, as they may be backed by other snapshots, a remote CAS, etc. etc. etc.. This change extends atomicallyWriteTo() to always write contents into a new file that is guaranteed to be writable. The logic that's added here is merely copy-pasted from what's already present at the bottom of the same function.
d412613 to
ef88553
Compare
Contributor
Author
|
@coeuvre @larsrc-google PTAL! |
coeuvre
approved these changes
Oct 5, 2023
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.
This change is the same in spirit to #19241. When using Bazel in combination with bb_clientd, bb_clientd may restore a copy of bazel-out/ from a snapshot. Files restored from the snapshot are not mutable, as they may be backed by other snapshots, a remote CAS, etc. etc. etc..
This change extends atomicallyWriteTo() to always write contents into a new file that is guaranteed to be writable. The logic that's added here is merely copy-pasted from what's already present at the bottom of the same function.