Skip to content

Register a FileValue dep on bzlCompileCache hits in BzlLoadFunction - #30902

Open
fmeum wants to merge 1 commit into
bazelbuild:masterfrom
fmeum:claude/bazel-issue-30900-gtza50
Open

Register a FileValue dep on bzlCompileCache hits in BzlLoadFunction#30902
fmeum wants to merge 1 commit into
bazelbuild:masterfrom
fmeum:claude/bazel-issue-30900-gtza50

Conversation

@fmeum

@fmeum fmeum commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Description

The KeyForBuild and KeyForBzlmod variants of a BzlLoadValue key for the same .bzl file share a single BzlCompileValue.Key, and thus a single entry in the bzlCompileCache used when BzlCompileFunction is inlined. When a BzlLoadValue node got a cache hit for an entry that was computed on behalf of a node of the other key variant, it never requested the FileValue for the .bzl file, so it was missing the Skyframe edge that would invalidate it when the file changes and kept serving stale file contents on subsequent builds.

Fix this by (re-)requesting the FileValue for the .bzl file on a cache hit.

Motivation

Fixes #30900

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

@google-cla

google-cla Bot commented Aug 27, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@bazel-docs-pr-commenter

Copy link
Copy Markdown

✅ Bazel docs preview is ready!

Preview URL: https://bazel-pr-30902.mintlify.app/

Updated for 4923d2e04bde0ddf01d97b8ba70af3f0a84d6986

The KeyForBuild and KeyForBzlmod variants of a BzlLoadValue key for the
same .bzl file share a single BzlCompileValue.Key, and thus a single
entry in the bzlCompileCache used when BzlCompileFunction is inlined.
When a BzlLoadValue node got a cache hit for an entry that was computed
on behalf of a node of the other key variant, it never requested the
FileValue for the .bzl file, so it was missing the Skyframe edge that
would invalidate it when the file changes and kept serving stale file
contents on subsequent builds.

Fix this by (re-)requesting the FileValue for the .bzl file on a cache
hit. For a cache hit caused by a Skyframe restart of the same node, the
dep is already registered and the request is cheap.

Fixes bazelbuild#30900.
@fmeum
fmeum force-pushed the claude/bazel-issue-30900-gtza50 branch from 4923d2e to 9535148 Compare August 27, 2026 21:32
@fmeum
fmeum requested a review from tetromino August 27, 2026 21:44
@fmeum
fmeum marked this pull request as ready for review August 27, 2026 21:44
@fmeum
fmeum requested a review from Wyverald August 27, 2026 21:44
@fmeum

fmeum commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

@bazel-io fork 9.3.0

@github-actions github-actions Bot added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc awaiting-review PR is awaiting review from an assigned reviewer labels Aug 27, 2026
@tetromino
tetromino requested a review from brandjon August 27, 2026 22:01
@tetromino

tetromino commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Very nice test case!

I'd like a review from @brandjon who has much more historical context about inlined vs. non-inlined compilation.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bazel uses out-of-date file contents when a bzl file is shared between BUILD and MODULE.bazel

3 participants