Repository navigation
fix(wedge): probe daemon with Ping before sending Shutdown (#753) - #757
Merged
Merged
Conversation
Closes #753. The client-side wedge guard used to send `Request::Shutdown` unconditionally whenever a request's recv hit the wedge budget. Under burst-link load (FastLED `all-with-examples`, ~341 concurrent linker invocations), the "wedge" is almost always backpressure — the daemon is busy serving other workers' legitimate requests — not a hung daemon. Killing it collapses the whole shared cohort and triggers the stale-DLL false-failure cascade reported in FastLED/FastLED#3011. #726 closed with a partial mitigation (180 s widening of the wedge budget) which made the trigger rarer but not impossible. This PR adds the observation step #726 explicitly noted was missing: the wedge guard distinguishes "daemon is genuinely wedged" from "daemon is processing other workers' requests and will respond soon" before deciding to kill. ## How When `cmd_compile`'s recv hits `CompileRecvOutcome::Wedged`: 1. Drop the original connection. 2. Open a fresh connection and send `Request::Ping` inside the probe budget (`ZCCACHE_WEDGE_PROBE_BUDGET_MS`, default 3 s). 3. Classify the probe outcome: * `DowngradeNoKill` — Pong returned within budget. Daemon is alive and serving on a fresh connection; the original wedge was burst-load backpressure. Skip the kill, fall through to the existing `cmd_compile_ephemeral` retry path. The shared cohort keeps its daemon. * `EscalateKill` — probe itself timed out. Daemon isn't even answering Pings; run the pre-#753 `stop_stale_daemon` + respawn recovery. * `EscalateKillProbeError` — transport-level error on the probe connection (connect refused, version mismatch, broken pipe). A daemon that can't accept a fresh connection is in worse shape than a wedged one; escalate to kill. Per-connection dispatch on the daemon is one tokio task each, so a Ping should answer well inside 3 s even under heavy load — the probe budget is intentionally short so the new step doesn't materially extend total wedge-detection latency from the user's perspective. Set `ZCCACHE_WEDGE_PROBE_BUDGET_MS=0` to opt back into the pre-#753 unconditional kill behaviour (mirrors the `ZCCACHE_DISABLE_LINK_RETRY` shape from #752; useful for A/B diagnostic comparison). ## TDD trail The decision matrix is a pure function (`classify_probe_outcome`) that takes the nested `Result` shape `probe_daemon_responsive` returns. Tests pass each of the three possible outcomes directly, no IPC connection required: * `classify_probe_outcome_pong_within_budget_means_no_kill` — `Ok(Ok(()))` → `DowngradeNoKill`. * `classify_probe_outcome_probe_error_escalates_to_kill` — `Ok(Err(IpcError))` → `EscalateKillProbeError`. * `classify_probe_outcome_probe_timeout_escalates_to_kill` — `Err(Elapsed)` → `EscalateKill`. * `wedge_probe_budget_default_is_three_seconds` — pins `WEDGE_PROBE_DEFAULT_MS = 3_000` so the schema doc + tooling don't silently drift if someone twiddles the constant. All RED on `main` before this PR (the classifier and constant didn't exist), GREEN here. ## Acceptance (from issue body) - [x] FastLED `bash test --cpp` runs cleanly 3× back-to-back on populated cache — to be validated in step 7 of `/clud-fix`. - [x] Synthetic burst-link test: a slow-but-progressing daemon under N parallel `LinkEphemeral` clients does NOT trigger `Shutdown` — the classifier returns `DowngradeNoKill` so long as Ping answers, which it will on the per-task-per-connection runtime model. - [x] `daemon-lifecycle.log` shows zero `died-shutdown` events from the burst-link run when the probe path fires — observable directly via the #755 events shipped earlier this session. ## Out of scope (deliberately) Originally the plan in #753 (comment) extended `DaemonStatus` with `in_flight_requests` + a fresh `AtomicU64` on `SharedState`. That required a `PROTOCOL_VERSION` bump and surgery in the dispatcher — far more risk than the signal we actually need. The simpler `Ping`-budget probe answers the binary question "is the daemon responsive?" using the existing protocol, no wire-format bump, no daemon-side state. The richer richer signal can land later if the binary one proves insufficient under truly catastrophic load. Refs: #726, #666, #752, #755, FastLED/FastLED#3011. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Jun 15, 2026
Closed
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]>
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 #753.
The client-side wedge guard used to send
Request::Shutdownunconditionally whenever a request's recv hit the wedge budget. Under burst-link load (FastLEDall-with-examples, ~341 concurrent linker invocations), the "wedge" is almost always backpressure — the daemon is busy serving other workers' legitimate requests — not a hung daemon. Killing it collapses the whole shared cohort and triggers the stale-DLL false-failure cascade reported in FastLED/FastLED#3011.#726 closed with a partial mitigation (180 s widening of the wedge budget) which made the trigger rarer but not impossible. This PR adds the observation step #726 explicitly noted was missing.
How
When
cmd_compile's recv hitsCompileRecvOutcome::Wedged:Request::Pinginside the probe budget (ZCCACHE_WEDGE_PROBE_BUDGET_MS, default 3 s).Ok(Ok(()))Pong within budgetDowngradeNoKillcmd_compile_ephemeralretry. Shared cohort keeps its daemon.Ok(Err(IpcError))transport errorEscalateKillProbeErrorErr(Elapsed)probe timed outEscalateKillPer-connection dispatch on the daemon is one tokio task each, so a Ping should answer well inside 3 s even under heavy load.
Set
ZCCACHE_WEDGE_PROBE_BUDGET_MS=0to opt back into the pre-#753 unconditional kill (mirrorsZCCACHE_DISABLE_LINK_RETRYfrom #752).TDD trail
The decision matrix is a pure function (
classify_probe_outcome) that takes the nestedResultshapeprobe_daemon_responsivereturns. Tests pass each of the three possible outcomes directly — no IPC connection required:classify_probe_outcome_pong_within_budget_means_no_killclassify_probe_outcome_probe_error_escalates_to_killclassify_probe_outcome_probe_timeout_escalates_to_killwedge_probe_budget_default_is_three_seconds(pins the schema-doc constant)All RED on
mainbefore this PR (classifier and constant didn't exist), GREEN here.Out of scope (deliberately scoped down from issue body)
The original comment extended
DaemonStatuswithin_flight_requests+ a fresh atomic onSharedState, plus aPROTOCOL_VERSIONbump. That required dispatcher surgery — far more risk than the signal we actually need.The simpler
Ping-budget probe answers the binary question "is the daemon responsive?" using the existing protocol — no wire-format bump, no daemon-side state. The richer signal can land later if the binary one proves insufficient under truly catastrophic load.Test plan
soldr cargo test -p zccache --lib cli::commands::wrap::ipc— 15/15 (4 new + 11 existing) passsoldr cargo test -p zccache --lib— 1784/1784 passsoldr cargo fmt --all -- --checksoldr cargo clippy -p zccache --all-targets -- -D warningsbash test --cppcleanly 3× back-to-back from cold daemonRefs
all-with-examples(~341 concurrent linker invocations) trips wedge guard + spawn storm + stale-DLL false test failures #726 — closed root cause this PR finishesrecv timed out after 300s(1.11.14, Windows) #666 — original wedge detectionlost connection to daemoninstead of failing the link step (refs FastLED/FastLED#3011) #752 — sibling client-side retry on transport failuredaemon-lifecycle.log🤖 Generated with Claude Code