Repository navigation
fix(graph): re-probe the cache after taking an action lock - #428
Merged
Merged
Conversation
Two targets that declare the same cacheable action could both run it. The second probed the cache while the first was running, then waited for an execution slot. The first released the slot and the action lock together once it stored its result, so the second took the lock without contention and skipped the re-probe that only ran on contention. This flaked spec/apple_explicit_modules_spec.sh on macOS CI, where Left and Right compile the same Clang modules and neither recorded a hit. Amp-Thread-ID: https://ampcode.com/threads/T-01a1c12d-ae66-702f-b51a-5ab9df400da2 Co-authored-by: Marek Fort <marek@tuist.dev>
fortmarek
force-pushed
the
fix/action-lock-reprobe
branch
from
November 9, 2026 21:50
4880c97 to
b9a35de
Compare
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.
Summary
Two targets that declare the same cacheable action could both run it. This is what made
spec/apple_explicit_modules_spec.sh:75fail intermittently onshellspec (macos-latest)(for example once run 42596832361 on main), whereLeftandRightcompile the same Clang modules and the spec expects one of them to reuse the other's result.The race:
The fix always re-probes after taking the lock and drops the now-unused contention flag from
with_action_lock_and_permit. The cost is one extra cache lookup per action that actually executes; with a remote cache, a true miss asks the remote twice.Verification
--cpu-limit 3): 18 of 36 runs failed, all at the shared.pcmcheck, with both targets recordingmissfor the sameNativeValue.pcm,SwiftShims.pcm, and_SwiftConcurrencyShims.pcmdigests. With the fix, 36 of 36 passed.shellspec spec/apple_explicit_modules_spec.sh: 3 examples, 0 failures.an_action_queued_behind_its_own_run_reuses_that_resultruns two builds of one action on a single slot. It fails on the old code (the action runs twice) and passes with the fix.cargo test -p once-cli --bin once commands::graph::analysis,cargo fmt --check, andcargo clippy -p once-cli --all-targets -D warningspass.