Skip to content

Commit

Permalink
[7.1.0] Ensure that the mtime of an AC entry is smaller, not larger, …
Browse files Browse the repository at this point in the history
…than the CAS blobs it references. (#21416)

7a774ff
got the condition backwards. Note that referential integrity isn't
required for correct operation, but lack of it can slow things down
unnecessarily.

PiperOrigin-RevId: 608354674
Change-Id: If56bb9211a5167d5db9e8eceb6224269758acdb1
  • Loading branch information
tjgq authored Feb 20, 2024
1 parent 61603f2 commit 3385486
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ public ListenableFuture<CachedActionResult> downloadActionResult(
}

return Futures.transformAsync(
// Update the mtime on the action result itself before any of the blobs it references.
// This ensures that the blobs are always newer than the action result, so that trimming the
// cache in LRU order cannot create dangling references.
Utils.downloadAsActionResult(actionKey, (digest, out) -> download(digest, out, Store.AC)),
actionResult -> {
if (actionResult == null) {
Expand All @@ -249,11 +252,6 @@ public ListenableFuture<CachedActionResult> downloadActionResult(
return immediateFuture(null);
}

// Update the mtime for the action result itself. This ensures that blobs are older than
// the action result, so that trimming the cache in LRU order will not create dangling
// references.
var unused = refresh(toPath(actionKey.getDigest(), Store.AC));

return immediateFuture(CachedActionResult.disk(actionResult));
},
MoreExecutors.directExecutor());
Expand Down

0 comments on commit 3385486

Please sign in to comment.