Skip to content

solver: advertise committed cache keys after exec - #6955

Merged
tonistiigi merged 4 commits into
moby:masterfrom
tonistiigi:6954-carry
Jul 21, 2026
Merged

solver: advertise committed cache keys after exec#6955
tonistiigi merged 4 commits into
moby:masterfrom
tonistiigi:6954-carry

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

alternative for #6954

@felixdesouza

Does not fix full #4674 but should be simpler alterative to the issue/repro in #6954

felixdesouza and others added 4 commits July 13, 2026 15:28
Diagnose the concurrency-triggered cross-build miss: build 2/13 never
queries because its shared base dependency is reused already-complete
(pinned in Solver.actives by a concurrent build) and hands over an
edgeState with zero cache keys, so probeCache/Query is never called and
noCacheMatchPossible latches the dep to complete-only.

Two probes, keyed by vertex digest:
- checkDepMatchPossible: WARN when noCacheMatchPossible flips, logging the
  dep's state/keys/keyMap and whether its result still carries a cache key
  (dep_result_keys>0 with dep_keymap==0 = the starvation).
- processDepReq: DEBUG on each cache-slow/complete dep delivery, logging
  edgeState keys vs result keys, so the fatal complete/0-key delivery in the
  concurrent run contrasts with the healthy cache-slow/keyed delivery in the
  serial run.

Keeps the earlier probeCache-skip WARN as a proven-negative.

Signed-off-by: Felix de Souza <fdesouza@palantir.com>
TestCacheMissStaleCompleteSharedDep reproduces the concurrency-triggered
miss in-process (no docker): a producer builds step->base fresh, a holder
job keeps only the shared base alive, the producer is discarded, then a
consumer builds a fresh step over the same (already-complete) base. On
pristine code the consumer re-executes (execCallCount=1) instead of
reusing the cached result; with the probeResultCache fix it reuses (0).

Verified to discriminate: fails on the pre-fix tree, passes with fafe01622.

Signed-off-by: Felix de Souza <fdesouza@palantir.com>
An edge that completes by executing never adds its committed cache keys
to edgeState.keys: the pre-execution cache query found nothing (that is
why it executed) and Save only attaches the keys to the result. A
consumer subscribing afterwards therefore receives zero keys, finds no
probeable match, latches noCacheMatchPossible and re-executes even
though its own cached record is intact.

Normally such an edge dies with its build; the next build recreates it,
re-queries the now-populated cache and delivers the key normally. But
when a concurrent build keeps the shared edge referenced in
Solver.actives, a later build reuses it already complete, inherits the
empty key list and re-runs steps that should have been cache hits
(moby#4674 family).

Append the committed result keys to edgeState.keys on completion so an
executed edge advertises its keys the same way a cache-hit edge does.
Skipped for cache loads, whose record key is already present, and for
ignore-cache edges, so that a --no-cache dependency does not let
consumers match records through a step that was forced to re-run.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
The regression test's comments described the earlier consumer-side fix
(probeResultCache reading a completed dep's result keys). The fix that
landed instead makes processExecReq append an executed edge's committed
keys to edgeState.keys on completion. Reword the mechanism references
accordingly; scenarios and assertions are unchanged and still
discriminate: the HeldCompleteBaseMisses subtests fail without the
append, and the ignore-cache subtest fails without its IgnoreCache
guard.

Also use t.Context() instead of context.TODO() and drop t.Parallel().

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi tonistiigi changed the title 6954 carry solver: advertise committed cache keys after exec Jul 13, 2026
@tonistiigi tonistiigi added this to the v0.32.0 milestone Jul 15, 2026
@tonistiigi
tonistiigi merged commit 4f4f9d5 into moby:master Jul 21, 2026
225 of 227 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants