Skip to content

[8.8.0] Preserve order of recorded inputs#29068

Merged
Wyverald merged 7 commits into
bazelbuild:release-8.8.0from
fmeum:rrcc-8.7.0-02
Jun 22, 2026
Merged

[8.8.0] Preserve order of recorded inputs#29068
Wyverald merged 7 commits into
bazelbuild:release-8.8.0from
fmeum:rrcc-8.7.0-02

Conversation

@fmeum

@fmeum fmeum commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Recorded inputs for repo rules and module extensions are no longer separated by type, but recorded in the order they are encountered. This is necessary preparatory work to avoid Skyframe cycles that could otherwise occur while checking cache, lockfile or marker file entries for up-to-dateness.

This requires a breaking change to the lockfile structure, but has the positive side effect that each recorded input is now represented as a single line in the lockfile and thus more compact.

Along the way, the error message for an out-of-date lockfile entry with --lockfile_mode=errors are improved and now include the precise reason for the invalidation.

For repository rules, the repo mapping entries recorded while loading the repo rule definition are now included in the predeclared inputs hash, which makes cache entries more specific and avoids unnecessary Skyframe lookups.

Work towards #27517

Closes #27603.

PiperOrigin-RevId: 844721202
Change-Id: Id063a88508591086b07bd89a822cf22b2d90610d
(cherry picked from commit 41ccfef)

@iancha1992 iancha1992 added this to the 8.7.0 release blockers milestone Mar 27, 2026
@iancha1992 iancha1992 added the soft-release-blocker Soft release blockers that are nice to have, but shouldn't block the release if it's the last one. label Apr 24, 2026
@iancha1992 iancha1992 changed the title [8.7.0] 02/23: Manual port of essential parts of: Preserve order of recorded inputs [8.8.0] 02/23: Manual port of essential parts of: Preserve order of recorded inputs May 7, 2026
@iancha1992 iancha1992 changed the base branch from release-8.7.0 to release-8.8.0 May 7, 2026 18:00
@github-actions

github-actions Bot commented Jun 7, 2026

Copy link
Copy Markdown

Thank you for contributing to the Bazel repository! This pull request has been marked as stale since it has not had any activity in the last 30 days. It will be closed in the next 30 days unless any other activity occurs. If you think this PR is still relevant and should stay open, please post any comment here and the PR will no longer be marked as stale.

@github-actions github-actions Bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 7, 2026
@fmeum fmeum changed the title [8.8.0] 02/23: Manual port of essential parts of: Preserve order of recorded inputs [8.8.0] Preserve order of recorded inputs Jun 15, 2026
@github-actions github-actions Bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Jun 16, 2026
fmeum added 6 commits June 19, 2026 09:12
I haven't been able to reproduce this in a test, but this should fix the following crash observed while running `bazel info`:
```
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NullPointerException: Cannot invoke "java.util.concurrent.ExecutorService.shutdownNow()" because "this.materializationExecutor" is null
	at com.google.devtools.build.lib.remote.RemoteExternalOverlayFileSystem.afterCommand(RemoteExternalOverlayFileSystem.java:145)
	at com.google.devtools.build.lib.remote.RemoteModule.afterCommand(RemoteModule.java:1034)
	at com.google.devtools.build.lib.runtime.BlazeRuntime.afterCommand(BlazeRuntime.java:787)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:807)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:266)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:608)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$0(GrpcServerImpl.java:679)
	at io.grpc.Context$1.run(Context.java:566)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
```

Closes bazelbuild#27690.

PiperOrigin-RevId: 833722608
Change-Id: I88c485a01e5967657ec3b5529a47639b743b18e6
(cherry picked from commit a7d0e91)
Don't print a message when it's successful. Users can always look under `external` to verify which repo came from the cache.

Closes bazelbuild#27699.

PiperOrigin-RevId: 834096735
Change-Id: I3916fb240218a6b68ecf48417142b998ca281598
(cherry picked from commit 3ca9ce1)
Fixes the creation of empty directories and also contains a speculative fix for the following issue observed during a sequence of real builds:

```
Error in path: Failed to materialize remote repo @@protoc-gen-validate+: [unix_jni.cc:302] /home/ubuntu/.cache/bazel/_bazel_ubuntu/123/external/protoc-gen-validate+/example-workspace/.bazelrc (File exists)
ERROR: //:foo :: Error loading option //:foo: error evaluating module extension @@gazelle+//:extensions.bzl%go_deps
```

The mentioned file is a symlink.

Closes bazelbuild#27711.

PiperOrigin-RevId: 836122472
Change-Id: I8becd8c3640a659d28dc433340db962c18563d9f
(cherry picked from commit b27ea05)
Ensures that the returned `Path` is still in the overlay file system.

Also make the error message emitted by `Path#checkSameFileSystem` more informative. This is motivated by and helped discover the above as the fix for the following crash observed when using the remote repo contents cache with an explicit `--sandbox_base`:

```
Caused by: java.lang.IllegalArgumentException: Files are on different filesystems: /dev/shm/bazel-sandbox.b10976335efa519b0184f3091ac8e21f7beefb92142303f9ab2c3341f45a2f28/linux-sandbox/18/execroot/_main/external/c-ares+/configs/ares_build.h (on com.google.devtools.build.lib.unix.UnixFileSystem@5e0a8154), /home/ubuntu/.cache/bazel/_bazel_ubuntu/123/execroot/_main/external/c-ares+/configs/ares_build.h (on com.google.devtools.build.lib.remote.RemoteExternalOverlayFileSystem@6cd9bfda)
        at com.google.devtools.build.lib.vfs.Path.checkSameFileSystem(Path.java:964)
        at com.google.devtools.build.lib.vfs.Path.createSymbolicLink(Path.java:523)
        at com.google.devtools.build.lib.vfs.Path.createSymbolicLink(Path.java:535)
        at com.google.devtools.build.lib.sandbox.SymlinkedSandboxedSpawn.copyFile(SymlinkedSandboxedSpawn.java:129)
```

Alternative to bazelbuild#27721

Closes bazelbuild#27802.

PiperOrigin-RevId: 837832265
Change-Id: I3b73167496b011aef66954d59ca3804b4b64996f
(cherry picked from commit 8eaf6a9)
Fixes bazelbuild#27981

Fixes the following type of crash and, incidentally, a remote repo contents cache test that resulted in a related crash:
```
    FATAL: bazel crashed due to an internal error. Printing stack trace:
    java.lang.IllegalStateException: Unknown error during configuration creation evaluation
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfiguration(SkyframeExecutor.java:2143)
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.createConfiguration(SkyframeExecutor.java:1876)
            at com.google.devtools.build.lib.analysis.BuildView.update(BuildView.java:281)
            at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.runAnalysisPhase(AnalysisPhaseRunner.java:399)
            at com.google.devtools.build.lib.buildtool.AnalysisPhaseRunner.execute(AnalysisPhaseRunner.java:144)
            at com.google.devtools.build.lib.buildtool.BuildTool.buildTargetsWithoutMergedAnalysisExecution(BuildTool.java:512)
            at com.google.devtools.build.lib.buildtool.BuildTool.buildTargets(BuildTool.java:414)
            at com.google.devtools.build.lib.buildtool.BuildTool.processRequest(BuildTool.java:907)
            at com.google.devtools.build.lib.runtime.commands.CqueryCommand.exec(CqueryCommand.java:197)
            at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:783)
            at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:266)
            at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:608)
            at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$0(GrpcServerImpl.java:679)
            at io.grpc.Context$1.run(Context.java:566)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            at java.base/java.lang.Thread.run(Unknown Source)
    Caused by: com.google.devtools.build.lib.skyframe.toolchains.PlatformLookupUtil$InvalidPlatformException: com.google.devtools.build.lib.packages.BuildFileNotFoundException: no such package '@@[unknown repo 'toolchains_llvm_boostrapped' requested from @@ (did you mean 'toolchains_llvm_bootstrapped'?)]//platforms': The repository '@@[unknown repo 'toolchains_llvm_boostrapped' requested from @@ (did you mean 'toolchains_llvm_bootstrapped'?)]' could not be resolved: No repository visible as '@toolchains_llvm_boostrapped' from main repository
            at com.google.devtools.build.lib.analysis.platform.PlatformFunction.compute(PlatformFunction.java:75)
            at com.google.devtools.build.lib.analysis.platform.PlatformFunction.compute(PlatformFunction.java:43)
            at com.google.devtools.build.skyframe.ParallelEvaluator.bubbleErrorUp(ParallelEvaluator.java:414)
            at com.google.devtools.build.skyframe.ParallelEvaluator.waitForCompletionAndConstructResult(ParallelEvaluator.java:207)
            at com.google.devtools.build.skyframe.ParallelEvaluator.doMutatingEvaluation(ParallelEvaluator.java:173)
            at com.google.devtools.build.skyframe.ParallelEvaluator.eval(ParallelEvaluator.java:672)
            at com.google.devtools.build.skyframe.AbstractInMemoryMemoizingEvaluator.evaluate(AbstractInMemoryMemoizingEvaluator.java:182)
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.evaluate(SkyframeExecutor.java:4279)
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.lambda$evaluateSkyKeys$0(SkyframeExecutor.java:2278)
            at com.google.devtools.build.lib.concurrent.Uninterruptibles.callUninterruptibly(Uninterruptibles.java:35)
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.evaluateSkyKeys(SkyframeExecutor.java:2274)
            at com.google.devtools.build.lib.skyframe.SkyframeExecutor.getConfiguration(SkyframeExecutor.java:2126)
            ... 16 more
```

Closes bazelbuild#28004.

PiperOrigin-RevId: 845941915
Change-Id: I6ead8dd1662efe90f529a6e21041a225882415dc
(cherry picked from commit d6dc631)
Recorded inputs for repo rules and module extensions are no longer separated by type, but recorded in the order they are encountered. This is necessary preparatory work to avoid Skyframe cycles that could otherwise occur while checking cache, lockfile or marker file entries for up-to-dateness.

This requires a breaking change to the lockfile structure, but has the positive side effect that each recorded input is now represented as a single line in the lockfile and thus more compact.

Along the way, the error message for an out-of-date lockfile entry with `--lockfile_mode=errors` are improved and now include the precise reason for the invalidation.

For repository rules, the repo mapping entries recorded while loading the repo rule definition are now included in the predeclared inputs hash, which makes cache entries more specific and avoids unnecessary Skyframe lookups.

Work towards bazelbuild#27517

Closes bazelbuild#27603.

PiperOrigin-RevId: 844721202
Change-Id: Id063a88508591086b07bd89a822cf22b2d90610d
(cherry picked from commit 41ccfef)
@fmeum fmeum marked this pull request as ready for review June 22, 2026 10:37
@fmeum fmeum requested a review from a team as a code owner June 22, 2026 10:37
@github-actions github-actions Bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. team-Core Skyframe, bazel query, BEP, options parsing, bazelrc team-Remote-Exec Issues and PRs for the Execution (Remote) team area-Bzlmod Bzlmod-specific PRs, issues, and feature requests awaiting-review PR is awaiting review from an assigned reviewer labels Jun 22, 2026
@iancha1992 iancha1992 requested a review from Wyverald June 22, 2026 18:50
@iancha1992 iancha1992 requested a review from lberki June 22, 2026 18:50
@Wyverald Wyverald added this pull request to the merge queue Jun 22, 2026
Merged via the queue into bazelbuild:release-8.8.0 with commit 30685f4 Jun 22, 2026
47 checks passed
@github-actions github-actions Bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Bzlmod Bzlmod-specific PRs, issues, and feature requests soft-release-blocker Soft release blockers that are nice to have, but shouldn't block the release if it's the last one. team-Core Skyframe, bazel query, BEP, options parsing, bazelrc 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.

3 participants