Wait for pending derivations before checking validity - #61
Open
jacobmichels wants to merge 2 commits into
Open
Conversation
jacobmichels
requested review from
joshheinrichs-shopify and
lilyinstarlight
September 6, 2026 03:17
Assisted-By: devx/bc79da8f-6a88-40b0-a3b3-26d3f8e0f7e1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
macOS CI on
mainintermittently fails inflakes / provenanceafter the test clears its store and restores a package from a binary cache. The provenance check reports that it cannot recreate the package's.drvfile (its build recipe).A validity lookup can race with an asynchronous recipe write. The write clears the cached metadata, but an earlier lookup can finish afterward and cache a stale “missing” result. Waiting only before the final validity check is too late.
Change
In
AttrCursor::forceDerivation(), wait for any queued write before the first validity lookup. Preserve regeneration for missing recipes and the second wait after regeneration. Put both waits and the validity checks inside!settings.readOnlyMode, so read-only evaluation returns the derivation path without waiting or checking its validity.This fixes the race at this call site. The broader path-info cache race, where a lookup can cache a stale result after invalidation, remains outside this change.
Retain the deterministic regression test that completes a write between a missing-path lookup and caching its result, using a temporary local store without threads or sleeps. Add a regression test that verifies read-only evaluation returns the path without waiting for a pending write.
Checks
nix develop -c meson compile -C build— passed.nix develop -c meson test -C build --no-rebuild --print-errorlogs nix-expr-tests eval-cache provenance— all three suites passed, including both regression tests.nix develop -c ./maintainers/format.sh— passed.Local checks ran on Linux. macOS confirmation remains with CI.