8000 Fix disk cache failures on concurrent read-write access on Windows by fmeum · Pull Request #28417 · bazelbuild/bazel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@fmeum
Copy link
Collaborator
@fmeum fmeum commented Jan 25, 2026

This applies the fix made to the download cache in 753dc97 to the disk cache.

Work towards #28408

@fmeum fmeum force-pushed the 28408-concurrency-fix branch from 453bb2c to 086cf9c Compare January 26, 2026 14:41
@fmeum fmeum force-pushed the 28408-concurrency-fix branch from b639ce2 to 89bac4a Compare January 27, 2026 15:07
@fmeum fmeum marked this pull request as ready for review January 27, 2026 15:38
@fmeum fmeum requested a review from a team as a code owner January 27, 2026 15:38
@fmeum fmeum requested a review from coeuvre January 27, 2026 15:38
@fmeum
Copy link
Collaborator Author
fmeum commented Jan 27, 2026

@bazel-io fork 8.6.0

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Remote-Exec Issues and PRs for the Execution (Remote) team awaiting-review PR is awaiting review from an assigned reviewer labels Jan 27, 2026
@fmeum
Copy link
Collaborator Author
fmeum commented Jan 27, 2026

@bazel-io fork 9.0.1

@fmeum
Copy link
Collaborator Author
fmeum commented Jan 27, 2026

@bazel-io fork 9.1.0

Copy link
@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request applies a fix for concurrent read-write access on Windows to the disk cache, mirroring a previous fix in the download cache. The changes correctly handle FileAccessException on Windows during file renames in concurrent scenarios. The new test case is well-designed to validate this fix. I've identified a few areas for improvement related to resource cleanup and error handling to make the implementation more robust.

Comment on lines 255 to 257
if (OS.getCurrent() != OS.WINDOWS || !cacheValue.exists()) {
throw e;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In DiskCacheClient, you've added logic to delete the temporary file in this situation, which is great for preventing resource leaks. A similar cleanup for tmpName seems to be missing here. When this FileAccessException is caught and handled as a benign race, the temporary file tmpName should be deleted to avoid leaving it behind in the cache directory.

if (OS.getCurrent() != OS.WINDOWS || !target.exists()) {
throw e;
}
src.delete();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If src.delete() throws an IOException, the entire operation will fail. Since we've determined this is a benign race condition where another thread has already successfully cached the file, this operation should not fail. The cleanup of the temporary file should be on a best-effort basis.

      try {
        src.delete();
      } catch (IOException ignored) {
        // Best-effort cleanup of the temporary file.
      }

if (OS.getCurrent() != OS.WINDOWS || !path.exists()) {
throw e;
}
temp.delete();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

If temp.delete() throws an IOException, the entire operation will fail. Since we've determined this is a benign race condition where another thread has already successfully cached the file, this operation should not fail. The cleanup of the temporary file should be on a best-effort basis.

      try {
        temp.delete();
      } catch (IOException ignored) {
        // Best-effort cleanup of the temporary file.
      }

fmeum added 2 commits January 28, 2026 16:18
This applies the fix made to the download cache in 753dc97 to the disk cache.
@fmeum fmeum force-pushed the 28408-concurrency-fix branch from 89bac4a to e0a92ad Compare January 28, 2026 15:30
@fmeum fmeum requested a review from coeuvre January 28, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Remote-Exec Issues and PRs for the Execution (Remote) team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0