Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4.1] Use ctime in file digest cache key #18102

Closed
wants to merge 2 commits into from
Closed

[5.4.1] Use ctime in file digest cache key #18102

wants to merge 2 commits into from

Conversation

keertk
Copy link
Member

@keertk keertk commented Apr 14, 2023

File digests are now additionally keyed by ctime for supported file system implementations. Since Bazel has a non-zero default for --cache_computed_file_digests, this may be required for correctness in cases where different files have identical mtime and inode number. For example, this can happen on Linux when files are extracted from a tar file with fixed mtime and are then replaced with mv, which preserves inodes.

Since Java (N)IO doesn't have support for reading file ctimes on Windows, a new method backed by a native implementation is added to WindowsFileOperation. Adding a call to this function to stat uncovered previously silent bugs where Unix-style PathFragments were created on Windows:

  1. Bzlmod's createLocalRepoSpec did not correctly extract the path from a registry's file:// URI on Windows.
  2. --package_path isn't usable with absolute paths on Windows as it splits on :. Since the flag is deprecated, this commit fixes the tests rather than the implementation.

Fixes #14723

Closes #18003.

Commit 763f1d9

PiperOrigin-RevId: 524297459
Change-Id: I96bfc0210e2f71bf8603c7b7cc5eb06a04048c85

fmeum and others added 2 commits April 14, 2023 09:55
File digests are now additionally keyed by ctime for supported file system implementations. Since Bazel has a non-zero default for `--cache_computed_file_digests`, this may be required for correctness in cases where different files have identical mtime and inode number. For example, this can happen on Linux when files are extracted from a tar file with fixed mtime and are then replaced with `mv`, which preserves inodes.

Since Java (N)IO doesn't have support for reading file ctimes on Windows, a new method backed by a native implementation is added to `WindowsFileOperation`. Adding a call to this function to `stat` uncovered previously silent bugs where Unix-style `PathFragment`s were created on Windows:

1. Bzlmod's `createLocalRepoSpec` did not correctly extract the path from a registry's `file://` URI on Windows.
2. `--package_path` isn't usable with absolute paths on Windows as it splits on `:`. Since the flag is deprecated, this commit fixes the tests rather than the implementation.

Fixes #14723

Closes #18003.

PiperOrigin-RevId: 524297459
Change-Id: I96bfc0210e2f71bf8603c7b7cc5eb06a04048c85
@keertk keertk added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Core Skyframe, bazel query, BEP, options parsing, bazelrc awaiting-review PR is awaiting review from an assigned reviewer labels Apr 14, 2023
@keertk keertk requested a review from ShreeM01 as a code owner April 14, 2023 17:09
@keertk keertk removed the request for review from ShreeM01 April 14, 2023 17:09
@keertk
Copy link
Member Author

keertk commented Apr 14, 2023

@Wyverald @meteorcloudy there are some problems with src/main/java/com/google/devtools/build/lib/bazel/bzlmod/IndexRegistry.java that I wasn't able to fix. Does another commit (ec3d03c?) need to be cherry-picked first?

Please lmk how to proceed. Thanks!

@meteorcloudy
Copy link
Member

/cc @fmeum Can you help backport this change properly to 5.4.1?

@fmeum
Copy link
Collaborator

fmeum commented Apr 17, 2023

@meteorcloudy @keertk I created #18115.

@keertk
Copy link
Member Author

keertk commented Apr 17, 2023

Thanks @fmeum!

@keertk keertk closed this Apr 17, 2023
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-Core Skyframe, bazel query, BEP, options parsing, bazelrc team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants