Repository navigation
fix(daemon): pipe-pool depletion + compile-path wedge recovery (refs #666) - #669
Merged
Merged
Conversation
…666) Issue #666: long-lived Windows daemon (1.11.14, ~1h uptime) stopped responding to RPC mid-build. Every parallel ninja worker hit the 300 s `DEFAULT_CLIENT_RECV_TIMEOUT` wall and reported `[FAILED]` even though the daemon process was still alive. Recovery required manual `taskkill /F /PID <daemon>`. Three layers of fix: - Layer C (root-cause): `IpcListener::accept()` on Windows used to silently shrink the pre-created named-pipe pool whenever the replacement `ServerOptions::create(...)` returned an error — the popped pipe was consumed without a replacement being pushed back. Sustained transient OS-handle failures eventually depleted the pool; the next accept would `pool.pop_front().expect("pipe pool must not be empty")` and panic. Replaced with: a bounded-backoff retry around replacement creation, a `connect()`-failure retry loop, and an emergency-create fallback when the pool ever empties. - Layer A (recovery): `cmd_compile` now wraps the response recv in the configurable `wedge_recv_timeout` (default 90 s, env override `ZCCACHE_WEDGE_RECV_TIMEOUT_SECS`, `0` disables). On timeout the wrapper force-kills the wedged daemon via the existing `stop_stale_daemon` helper (release the pipe endpoint and unblock other workers queued on `pipe.connect()`) and falls back to `cmd_compile_ephemeral` so the user's compile still succeeds. Only the first worker to hit the wedge pays the recovery cost; subsequent workers find no daemon and take the normal spawn path. - Layer B (defense-in-depth): `cmd_compile_ephemeral` and `cmd_link_ephemeral` get the same wedge detection but without retry — they're already on a fresh-daemon path via `ensure_daemon`, so the right behaviour on wedge is fast-fail + kill so the build framework's per-job retry budget isn't blown. Tests: - `pool_recovers_from_full_depletion` (transport.rs): drains the pool fully and asserts accept still serves a client (would have panicked pre-fix). - `wedge_detection_{returns_done_on_normal_response,returns_wedged_on_recv_timeout,does_not_misclassify_broken_pipe_as_wedge,disabled_when_env_is_zero}` (wrap/ipc.rs): exhaustive table for the recv classifier; broken pipe must NOT trigger the recovery path (force-killing the daemon on every protocol mismatch would be a worse cure than the disease). Hypothesis writeup posted as <#666 (comment)>. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
force-pushed
the
fix/666-daemon-wedge-recovery
branch
from
June 5, 2026 07:02
ba53179 to
3399de5
Compare
This was referenced Jun 5, 2026
zackees
added a commit
that referenced
this pull request
Jun 5, 2026
Cuts a patch release from current main so the wedge-recovery fix from PR #669 (`fix(daemon): pipe-pool depletion + compile-path wedge recovery`) reaches PyPI. 1.11.14 was published 2026-06-04 23:24 UTC; #669 merged 2026-06-05 07:02 UTC, which means every 1.11.14 user is still seeing the steady-state daemon wedge under heavy parallel-build load. No code changes in this commit — release-auto.yml triggers off the Cargo.toml `workspace.package.version` bump. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
to FastLED/FastLED
that referenced
this pull request
Jun 5, 2026
zccache 1.11.15 (forge-ci/zccache#671) is the first release to ship the daemon-wedge recovery from forge-ci/zccache#669: - Layer A — wrap path detects daemon wedge via 90s configurable recv timeout, force-kills the wedged daemon, falls back to ephemeral compile so the build completes - Layer B — same wedge detection on ephemeral paths (fast-fail) - Layer C — `IpcListener::accept()` on Windows no longer silently shrinks the named-pipe pool on transient OS errors 1.11.14 users (this repo's current pin) are still seeing the steady- state daemon wedge under heavy parallel-build load (~670 TUs reproduces it reliably on Windows), because the recovery layers from #669 only ship in 1.11.15. Forcing the minimum to 1.11.15 prevents new contributors from picking up the broken-on-Windows 1.11.14 baseline. NOTE: This PR updates `pyproject.toml` only — `uv.lock` regeneration should happen after 1.11.15 lands on PyPI (run `uv lock` then squash into this commit, or land as a follow-up). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
to FastLED/fbuild
that referenced
this pull request
Jun 5, 2026
zccache 1.11.15 (forge-ci/zccache#671) is the first release to ship the daemon-wedge recovery from forge-ci/zccache#669: - Layer A — wrap path detects daemon wedge via 90s configurable recv timeout, force-kills the wedged daemon, falls back to ephemeral compile so the build completes - Layer B — same wedge detection on ephemeral paths (fast-fail) - Layer C — `IpcListener::accept()` on Windows no longer silently shrinks the named-pipe pool on transient OS errors 1.11.14 users (this repo's current pin) are still seeing the steady- state daemon wedge under heavy parallel-build load (~670 TUs reproduces it reliably on Windows), because the recovery layers from #669 only ship in 1.11.15. `>=1.11.15` still allows 1.11.x and 1.12.x; it just forbids the known- broken-on-Windows 1.11.14. Sister PR: FastLED/FastLED#2835 — bumps the same pin in FastLED. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
pull Bot
pushed a commit
to manmuqingshan/FastLED
that referenced
this pull request
Jun 6, 2026
zccache 1.11.15 (forge-ci/zccache#671) is the first release to ship the daemon-wedge recovery from forge-ci/zccache#669: - Layer A — wrap path detects daemon wedge via 90s configurable recv timeout, force-kills the wedged daemon, falls back to ephemeral compile so the build completes - Layer B — same wedge detection on ephemeral paths (fast-fail) - Layer C — `IpcListener::accept()` on Windows no longer silently shrinks the named-pipe pool on transient OS errors 1.11.14 users (this repo's current pin) are still seeing the steady- state daemon wedge under heavy parallel-build load (~670 TUs reproduces it reliably on Windows), because the recovery layers from FastLED#669 only ship in 1.11.15. Forcing the minimum to 1.11.15 prevents new contributors from picking up the broken-on-Windows 1.11.14 baseline. NOTE: This PR updates `pyproject.toml` only — `uv.lock` regeneration should happen after 1.11.15 lands on PyPI (run `uv lock` then squash into this commit, or land as a follow-up). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
zackees
added a commit
to FastLED/FastLED
that referenced
this pull request
Jun 7, 2026
Brings in two upstream fixes that map directly to symptoms hit during the recent `clud-pr` parallel-build worktree iterations: - **1.11.16** — adaptive daemon-spawn wait keyed on lockfile PID (forge-ci/zccache#674, closes #673). Fixes the thundering-herd "daemon started but not accepting connections after 10s" wedge that surfaced as `zccache[err][R]: lost connection to daemon (no response)` during heavy parallel build jobs. The bundled error message hint about "daemon-CLI protocol version mismatch" was misleading — the real cause is the daemon hangup during the herd window. - **1.11.17** — docs-only release that surfaces `ZCCACHE_PATH_REMAP` in `zccache --help` (forge-ci/zccache#676). The wedge-recovery work that landed in 1.11.15 (forge-ci/zccache#669 refs #666) is the previous pin floor; the new floor at 1.11.17 picks up the thundering-herd fix on top. Verified locally: ``` .venv/Scripts/zccache.exe --version zccache 1.11.17 ``` Refs forge-ci/zccache#673, #674.
zackees
added a commit
that referenced
this pull request
Jun 7, 2026
…connection message (#678) The user-facing daemon hangup message historically read: zccache[err][R]: lost connection to daemon (no response). Often a daemon-CLI protocol version mismatch — try `zccache stop` That hint was misleading. The actual cause of `Ok(None) => Err(...)` on the CLI's recv path is the daemon closing its side of the pipe without sending a Response frame. The two real-world triggers that produced this signal in FastLED's `clud-pr` parallel builds were: - thundering-herd "daemon started but not accepting connections after 10s" wedge — fixed in 1.11.16 (#674, closes #673) - pipe-pool depletion / compile-path wedge after ~1h uptime on Windows — fixed in 1.11.15 (#669, refs #666) With both fixes shipped, the remaining real causes are an external `zccache stop` or kill mid-request, or a genuine daemon crash — neither of which is "protocol version mismatch". Centralize the user-facing copy in `util::LOST_CONNECTION_MSG` and update all 7 call sites (`cache_ops`, `daemon`, `session` ×3, `status`, `wrap/ipc` ×2) to use it. The new copy points users at `zccache status` first, then a stop+retry recovery. The lower-level `Ok(None) => Err("lost connection to daemon (no response received)")` strings inside `client.rs` are left alone — they don't carry the misleading hint, and they're internal Result strings consumed by other layers, not user-facing. Refs FastLED#2889, zccache#666, zccache#673.
zackees
added a commit
to FastLED/FastLED
that referenced
this pull request
Jun 7, 2026
Picks up forge-ci/zccache#678 — drops the misleading "Often a daemon-CLI protocol version mismatch — try `zccache stop`" hint from the user-facing `lost connection to daemon (no response)` error message. That text was written before the thundering-herd (forge-ci/zccache#674) and pipe-pool (forge-ci/zccache#669) fixes landed in 1.11.16 / 1.11.15; with those gone the remaining real causes are an external `zccache stop`/kill mid-request or a daemon crash, neither of which is "protocol version mismatch". The new copy is centralized in `util::LOST_CONNECTION_MSG`, points users at `zccache status` first, then a stop+retry recovery. All 7 user-facing call sites (`cache_ops`, `daemon`, `session` ×3, `status`, `wrap/ipc` ×2) now share the single constant. Local verification: ``` .venv/Scripts/zccache.exe --version zccache 1.11.18 ``` Refs forge-ci/zccache#678.
zackees
added a commit
that referenced
this pull request
Jun 7, 2026
…partial) (#670) Phase 1 — pipe pool sizing (transport.rs): - The Windows named-pipe pool size cap was hard-coded `.min(16)`, which made the OS-level accept queue the dominant bottleneck under a 670-TU ninja burst. Clients hit `ERROR_PIPE_BUSY` before the daemon ever saw the request, which aliased "daemon overloaded" with "daemon dead" at the client (drove the Layer A/B/C wedge-recovery path from #669 on every natural overload, not just true wedges). - Pool now defaults to `clamp(cpu_count * 4, 16..=128)` with env override via `ZCCACHE_PIPE_POOL_SIZE`. On a 16-core box that's 64 vs the previous 16. Moves the bottleneck inside the daemon where overload can be expressed as a Response::Backpressure reply (Phase 2). Phase 2 — protocol surface (protocol/messages/mod.rs): - New `Response::Backpressure { queue_depth, retry_after_ms, reason }` variant, appended at end of the enum to preserve bincode variant indices for older clients (existing convention used by FingerprintCheckResult, RustArtifactList, GenericToolExecResult). - Daemon-side emission (queue depth threshold check + jittered retry hint) and client-side retry loop with budget + fallback to ephemeral remain TODO — blocked on local disk space for cargo check during this session. Design intent (full doc to land in a follow-up): ACCEPT layer (this commit) — pool sized for expected burst, never reject at the OS layer DISPATCH layer (next commit) — daemon reads request, evaluates real pressure metric, emits Backpressure on overload CLIENT layer (next commit) — honors retry_after_ms with jittered backoff and a budget; falls through to ephemeral on budget exhaustion Refs the daemon-wedge work in #669 (which catches true wedges via Layer A's 90 s recv timeout + force-kill); this series catches the *high load* case in-band so #669's recovery does not fire on natural overload.
This was referenced Jun 13, 2026
zackees
added a commit
that referenced
this pull request
Jun 15, 2026
#754) 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]>
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.
Summary
Fixes the wedge from #666: a long-lived Windows daemon stopped responding mid-build and every parallel ninja worker paid the full 300 s
DEFAULT_CLIENT_RECV_TIMEOUTwall before reporting[FAILED]. Recovery required manualtaskkill /F.Three layers:
IpcListener::accept()on Windows silently shrank the pre-created named-pipe pool whenever the replacementServerOptions::create(...)returnedErr. Sustained transient OS hiccups eventually depleted the pool, andpool.pop_front().expect(...)would panic. Replaced with a bounded-backoff retry around replacement creation, aconnect()-failure retry loop, and an emergency-create fallback when the pool ever empties.cmd_compilewraps the response recv in a configurablewedge_recv_timeout(default 90 s, envZCCACHE_WEDGE_RECV_TIMEOUT_SECS,0disables). On timeout: force-kill the wedged daemon via the existingstop_stale_daemonhelper (releases the pipe endpoint, unblocks other workers queued onpipe.connect()) and fall back tocmd_compile_ephemeralso the user's compile still succeeds. Only the first worker to hit the wedge pays the recovery cost.cmd_compile_ephemeralandcmd_link_ephemeralget the same wedge detection (no retry — they're already on a fresh-daemon path).Full hypothesis writeup: #666 (comment)
Test plan
soldr cargo test -p zccache --lib— 1708 passed, 0 failedsoldr cargo clippy -p zccache --all-targets -- -D warnings— cleansoldr cargo fmt --all— cleanpool_recovers_from_full_depletion(new regression test): drains the pool fully and asserts accept still serves a client (would have panicked pre-fix)wedge_detection_*× 4 (new regression tests): exhaustive table for the recv classifier — broken pipe MUST NOT trigger the recovery path🤖 Generated with Claude Code