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

Be resilient to outdated exec paths in action cache entries #23227

Closed
wants to merge 1 commit into from

Conversation

Wyverald
Copy link
Member

@Wyverald Wyverald commented Aug 6, 2024

60924fd changed the canonical repo name separator from ~ to +. Older repo names containing ~ now trigger a syntax error. If an action cache entry refers to an exec path from a previous version of Bazel that used ~, we need to be resilient and treat the cache entry as corrupted, rather than just crash.

Fixes #23180.

60924fd changed the canonical repo name separator from `~` to `+`. Older repo names containing `~` now trigger a syntax error. If an action cache entry refers to an exec path from a previous version of Bazel that used `~`, we need to be resilient and treat the cache entry as corrupted, rather than just crash.

Fixes #23180.
@Wyverald Wyverald requested a review from fmeum August 6, 2024 18:24
@Wyverald Wyverald requested a review from lberki as a code owner August 6, 2024 18:24
@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules awaiting-review PR is awaiting review from an assigned reviewer labels Aug 6, 2024
@Wyverald
Copy link
Member Author

Wyverald commented Aug 6, 2024

Tested with:

cd github/bazel
USE_BAZEL_VERSION=7.2.1 bazelisk build src:bazel  # succeeds
cp bazel-bin/src/bazel /tmp/bazel
USE_BAZEL_VERSION=last_green bazelisk build src:bazel  # crashes
/tmp/bazel build src:bazel  # succeeds

I'm still looking for a place to add tests. Any hints would be welcome :)

@Wyverald Wyverald requested a review from justinhorvitz August 6, 2024 18:28
@Wyverald
Copy link
Member Author

Wyverald commented Aug 6, 2024

After digging around the code base a bit, it's still unclear where I should add tests for this.

The only thing I can think of is to have an integration test that builds with --noincompatible_use_plus_in_repo_names first, and then with --incompatible_use_plus_in_repo_names. But such a test could only work on release-7.3.0, since the flag is a no-op on master.

@justinhorvitz
Copy link
Contributor

justinhorvitz commented Aug 6, 2024

The issue is action cache sharing across bazel versions? Would it be easier to increment https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/actions/cache/CompactPersistentActionCache.java;l=81;drc=f806a2ac39d1cf073207b8ecd5cb5cbcb8c4337b as a fix (#23224 is already going to do this)?

@Wyverald
Copy link
Member Author

Wyverald commented Aug 6, 2024

That would work, except that entries could be "poisoned" in the same version due to a flag flip. So unless we can "flip" the action cache version between two numbers (which is actually what we're doing with the MODULE.bazel.lock file version), this PR is still necessary.

@justinhorvitz
Copy link
Contributor

I'm not very familiar with the callers of discoverFromExecPath. What happens after they ignore the empty Optional? Does the crashing build now succeed?

@Wyverald
Copy link
Member Author

Wyverald commented Aug 6, 2024

Does the crashing build now succeed?

Yes (see #23227 (comment)).

What happens after they ignore the empty Optional?

The caller of ActionExecutionFunction.PackageRootResolverWithEnvironment#findPackageRootsForFiles (this line) then tries to retrieve the package root for each unresolved path. So the sourceRoots.get(path) here will simply return null, which eventually leads to this comment which suggests that a null is fine.

@justinhorvitz
Copy link
Contributor

Thanks, that explanation is very helpful.

@copybara-service copybara-service bot closed this in 7e689a5 Aug 6, 2024
@Wyverald Wyverald deleted the wyv-action-cache branch August 6, 2024 21:54
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Aug 6, 2024
Wyverald added a commit that referenced this pull request Aug 6, 2024
60924fd changed the canonical repo name separator from `~` to `+`. Older repo names containing `~` now trigger a syntax error. If an action cache entry refers to an exec path from a previous version of Bazel that used `~`, we need to be resilient and treat the cache entry as corrupted, rather than just crash.

Fixes #23180.

Closes #23227.

PiperOrigin-RevId: 660105601
Change-Id: Iea5d86c635056d12ba20598383da463bdde03ab0
github-merge-queue bot pushed a commit that referenced this pull request Aug 6, 2024
…23230)

60924fd
changed the canonical repo name separator from `~` to `+`. Older repo
names containing `~` now trigger a syntax error. If an action cache
entry refers to an exec path from a previous version of Bazel that used
`~`, we need to be resilient and treat the cache entry as corrupted,
rather than just crash.

Fixes #23180.

Closes #23227.

PiperOrigin-RevId: 660105601
Change-Id: Iea5d86c635056d12ba20598383da463bdde03ab0
keertk added a commit that referenced this pull request Aug 12, 2024
60924fd
changed the canonical repo name separator from `~` to `+`. Older repo
names containing `~` now trigger a syntax error. If an action cache
entry refers to an exec path from a previous version of Bazel that used
`~`, we need to be resilient and treat the cache entry as corrupted,
rather than just crash.

Fixes #23180.

Closes #23227.

PiperOrigin-RevId: 660105601
Change-Id: Iea5d86c635056d12ba20598383da463bdde03ab0

Co-authored-by: Xdng Yng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

action cache inputs with old ~ external module naming poison fresh builds
2 participants