Skip to content

Commit

Permalink
Avoid creating many distinct suffixes for the atomic writes of action…
Browse files Browse the repository at this point in the history
… inputs.

PiperOrigin-RevId: 515354520
Change-Id: I0b7fbe964f378c66fe69f9cfabc729718b9811a7
  • Loading branch information
larsrc-google authored and copybara-github committed Mar 9, 2023
1 parent 10587b1 commit c7f5c81
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,17 @@ public SandboxInputs processInputFiles(
PathFragment pathFragment = e.getKey();
ActionInput actionInput = e.getValue();
if (actionInput instanceof VirtualActionInput) {
// TODO(larsrc): Figure out which VAIs actually require atomicity, maybe avoid it.
VirtualActionInput input = (VirtualActionInput) actionInput;
byte[] digest =
input.atomicallyWriteRelativeTo(
execRootPath,
// When 2 actions try to atomically create the same virtual input, they need to have
// a different suffix for the temporary file in order to avoid racy write to the
// same one.
".sandbox" + tempFileUniquifierForVirtualInputWrites.incrementAndGet());
"_sandbox"
+ tempFileUniquifierForVirtualInputWrites.incrementAndGet()
+ ".virtualinputlock");
virtualInputs.put(input, digest);
}

Expand Down

0 comments on commit c7f5c81

Please sign in to comment.