Repository navigation
fix(wrap): auto-retry link/compile-ephemeral on lost-connection (#752) - #754
Merged
Merged
Conversation
Closes #752. Cross-ref FastLED/FastLED#3011. ## Why `cmd_link_ephemeral` and `cmd_compile_ephemeral` used to bail with `ExitCode::FAILURE` on any `CompileRecvOutcome::Failed` — including the FastLED-burst-link symptom where one client's wedge guard triggered a `Request::Shutdown` of a busy-but-alive daemon, and the ~40 other in-flight workers then got `lost connection to daemon`. Stale DLLs from prior builds remained, FastLED's #3011 stale-artifact detector flagged them, false test failures cascaded. This PR is the **relief layer**: it makes the recovery the error message itself recommends (`zccache stop` + retry) automatic on the client side. It does NOT address the underlying wedge-guard-vs- legitimate-work distinction tracked at #753 (filed separately). After #753 lands, this retry becomes defense-in-depth for non-wedge connection-loss modes (daemon OOM, OS network glitch). ## How * `link_with_retry` — generic async helper that runs an `attempt` closure and on `CompileRecvOutcome::Failed` runs a `recover` closure and retries up to `max_recoveries` times. Wedge outcomes bypass retry (intentionally fail-fast on ephemeral arms per #666). * Production recover closure is `retry_backoff_with_jitter` — a jittered 50–250 ms sleep, NOT a daemon kill. `ensure_daemon` on the next attempt already handles a dead daemon (probe → CommError → stop + respawn), and unconditionally killing here would race a healthy daemon another worker just spawned. * Retry budget is 1 by default, controlled by `link_retry_budget()`. `ZCCACHE_DISABLE_LINK_RETRY=1` opts back into pre-fix fail-fast behavior (mirrors the `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS=0` shape). * `run_ephemeral_attempt` extracts the ensure-daemon → connect → send → recv cycle so a retry covers ALL pre-recv failures (daemon spawn error, connect error, send error) uniformly — any of these can manifest as the burst-link spawn-storm shape. ## TDD trail (5 new unit tests) All RED on `main` before the helper existed, GREEN after: * `link_retry_returns_done_when_first_attempt_succeeds` — first-attempt success does not invoke recovery. * `link_retry_recovers_after_one_transport_failure` — the symptom this PR fixes: first `Failed`, second `Done` → outcome is `Done` and recovery was invoked exactly once. * `link_retry_surfaces_failure_after_exhausting_budget` — bounded: two `Failed` in a row surface as `Failed` with attempts=2, recoveries=1 (no infinite loop). * `link_retry_does_not_retry_on_wedge` — `Wedged` outcomes bypass recovery so the ephemeral wedge path stays fail-fast. * `link_retry_disabled_when_budget_is_zero` — env-var override. ## Caveats audited * No thundering-herd amplification: recovery is sleep+jitter, NOT a daemon kill, so N parallel workers all retrying don't pile a spawn storm. * Cap at 1 spawn-respawn per worker (budget=1 default). * Healthy-daemon detection is delegated to `ensure_daemon` which probes the version endpoint before any kill. ## Refs * #752 — this fix's tracking issue. * #753 — sibling root-cause issue (wedge guard kills legitimate in-flight work). This retry is the relief layer; #753 is the cure. * #666, #669 — wedge detection design + pool-replenishment fix that the retry complements. * #726 — closed root-cause issue this PR re-opens as #753 with sharper framing. * #745 — env-race lesson: the unit tests use closure-captured `AtomicU32` counters, not process-global env mutation. * FastLED/FastLED#3011 — downstream stale-DLL detection (consumer side). * FastLED/FastLED#3048 — adjacent native-file lifecycle bug (fixed in 1.12.5 via #750). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 of 3 tasks
zackees
added a commit
that referenced
this pull request
Jun 15, 2026
Ships three reliability + observability changes on top of 1.12.5: - fix(wrap): auto-retry link/compile-ephemeral on lost-connection (#754) - feat(observability): daemon-died / pipe-handover / client-disconnected lifecycle events (#756) - fix(wedge): probe daemon with Ping before sending Shutdown (#757) Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 15, 2026
Closed
2 of 7 tasks
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.
Closes #752. Cross-ref: FastLED/FastLED#3011.
Why (sharpened reframe)
Original symptom: under FastLED's
all-with-examplesninja target (~341 concurrent linker invocations), individual link clients hitlost connection to daemon, ninja marks the target FAILED, the prior build's.dllis left on disk, FastLED's #3011 stale-artifact detector flags it, false test failures cascade. The error message itself says to fix it withzccache stop+ retry — this PR makes that automatic.After investigating: the failure shape is NOT a daemon segfault and NOT a connection-refusal thundering herd. It's the client-side wedge guard killing a busy-but-alive daemon (
Request::Shutdown) when one client's 180 s recv budget expires under the burst-write load. ~40 other in-flight workers then see their connection close. The retry recovers that follow-on; the wedge-guard misfire itself is tracked at #753.How
link_with_retry— generic async helper. Runsattempt(); onCompileRecvOutcome::Failedrunsrecover()and re-runsattempt(). Bounded bymax_recoveries. Wedge outcomes bypass retry (ephemeral arms intentionally fail-fast per Daemon stops responding after ~1h uptime — all clients hitrecv timed out after 300s(1.11.14, Windows) #666).retry_backoff_with_jitter(50–250 ms randomized sleep), NOT a daemon kill.ensure_daemon's next call already handles a dead daemon (probe →CommError→ stop + respawn), and unconditionally killing here would race a healthy daemon another worker just spawned.ZCCACHE_DISABLE_LINK_RETRY=1(mirrors theZCCACHE_WEDGE_RECV_TIMEOUT_SECS=0shape).run_ephemeral_attemptfolds ensure-daemon → connect → send → recv into one closure so a single retry covers ALL pre-recv failure modes uniformly.TDD trail (5 new unit tests, all RED on
main, GREEN here)link_retry_returns_done_when_first_attempt_succeedslink_retry_recovers_after_one_transport_failureFailedthenDone→ outcomeDone, recoveries=1link_retry_surfaces_failure_after_exhausting_budgetFailedsurface asFailedwith attempts=2, no infinite looplink_retry_does_not_retry_on_wedgeWedgedoutcomes bypass recovery (ephemeral wedge stays fail-fast)link_retry_disabled_when_budget_is_zeroCaveats audited
ensure_daemonprobes the version endpoint before any kill; we don't pre-emptively kill a daemon another worker just spawned.Failedin a row surface to caller.Test plan
soldr cargo test -p zccache --lib cli::commands::wrap::ipc::tests— 11/11 passsoldr cargo fmt --all -- --checksoldr cargo clippy -p zccache --all-targets -- -D warningsbash test --cppcold-daemon run succeeds withoutzccache stopRefs
lost connection to daemoninstead of failing the link step (refs FastLED/FastLED#3011) #752 — this fix's tracking issuerecv timed out after 300s(1.11.14, Windows) #666, fix(daemon): pipe-pool depletion + compile-path wedge recovery (refs #666) #669 — wedge detection design + pool-replenishment fix the retry complementsall-with-examples(~341 concurrent linker invocations) trips wedge guard + spawn storm + stale-DLL false test failures #726 — closed root-cause issue whose closing commit partially mitigated the wedge wideningset_var/remove_var)🤖 Generated with Claude Code