Skip to content

fix(daemon,ci): tolerate unknown sessions and stop killing soldr's daemon (closes #166, #167) - #168

Merged
zackees merged 1 commit into
mainfrom
fix/daemon-session-and-zccache-ci-conflict
May 11, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/daemon-session-and-zccache-ci-conflict

Conversation

@zackees

@zackees zackees commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two coupled fixes for the soldr/zccache daemon-restart conflict surfaced in #166 and #167.

Why both at once

They're the same bug viewed from opposite ends:

  1. kill_daemon() (in zccache-ci: kill_daemon disrupts soldr-managed daemon mid-build (root cause for #166) #167) is the trigger.
  2. The hard error in handle_compile (in daemon: make Compile path idempotent for unknown sessions (mirror #137) #166) is the failure mode that made the trigger fatal.

Fixing only #167 leaves the next caller that legitimately needs to kill the daemon (Windows binary replacement, antivirus quarantine, OS restart) producing the same crash. Fixing only #166 leaves zccache-ci silently nuking soldr's session every stop hook and cold-compiling the world. Together they make stop-hook behaviour both correct and resilient.

Changes

File Change
crates/zccache-ci/src/main.rs Drop kill_daemon() from startup; keep reap_orphan_daemons(). Update surrounding comment. Drop the now-unused kill_daemon import.
crates/zccache-ci/src/lib.rs Update kill_daemon doc comment with a WARNING pointing at #167. Function itself unchanged — still public and tested.
crates/zccache-daemon/src/server.rs Replace the 5-line unknown-session check in handle_compile with an explanatory comment. Add regression test cli_compile_unknown_uuid_is_idempotent mirroring the existing cli_session_end_unknown_uuid_is_idempotent pattern.

Net: +80 / -14 across 3 files.

Verification (local, Windows)

  • soldr cargo check --workspace --all-targets — pass
  • soldr cargo clippy --workspace --all-targets -- -D warnings — pass
  • soldr cargo fmt --all --check — clean
  • soldr cargo test -p zccache-daemon --lib — 148 pass / 0 fail / 10 ignored
  • soldr cargo test -p zccache-daemon --lib -- cli_compile_unknown_uuid_is_idempotent --include-ignored — pass
  • soldr cargo test -p zccache-ci --lib — 10 pass / 0 fail

Test plan

  • CI: workspace check + clippy + fmt clean across Linux / macOS / Windows
  • CI: zccache-daemon and zccache-ci library tests pass
  • Integration job: the new cli_compile_unknown_uuid_is_idempotent test (covered by cargo test --workspace) passes when #[ignore] tests are executed
  • Manual: stop-hook on Windows no longer logs unknown session: <uuid> failures from rustc -vV probes

Related

…emon (closes #166, #167)

Two coupled fixes for the same conflict:

#167 (root cause): zccache-ci's `kill_daemon()` ran at every stop-hook
startup and took down the soldr-managed daemon mid-build, severing the
session soldr had just allocated. None of the current stop-hook stages
(check/clippy/test --exclude zccache-daemon) actually rebuild
`zccache-daemon.exe`, so the kill was never necessary on this path. Drop
the unconditional call; keep `reap_orphan_daemons` since that only
touches daemons whose parent PID is already gone. Doc-comment on the
still-public `kill_daemon` now warns future callers.

#166 (defensive): the daemon's Compile handler short-circuited with
`Response::Error { "unknown session: <uuid>" }` if the session map didn't
know the UUID — exactly the failure mode triggered after a kill. Mirror
PR #137's idempotent SessionEnd fix: drop the gate and let the compile
proceed. `record_session_stat`, `sessions.touch`, and `session_client_pid`
already no-op on unknown sessions, so the only loss is per-session
statistics — never a build failure.

Regression test `cli_compile_unknown_uuid_is_idempotent` (mirrors
`cli_session_end_unknown_uuid_is_idempotent`): sends Compile with a
well-formed-but-unknown UUID and asserts the response is not an
"unknown session" error.

Verification: workspace check + clippy + fmt clean; daemon `--lib` tests
148 pass / 10 ignored; zccache-ci `--lib` tests 10 pass; new regression
test passes under `--include-ignored`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit 5179171 into main May 11, 2026
10 of 12 checks passed
@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 44 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/zccache-daemon/src/server.rs 0.00% 44 Missing ⚠️

📢 Thoughts on this report? Let us know!

zackees added a commit to forge-ci/soldr that referenced this pull request May 11, 2026
…265) (#267)

When the managed zccache daemon is killed mid-build (e.g. zccache-ci's
stop hook on older zccache, Windows binary replacement, or AV
quarantine), every subsequent wrapper invocation fails with
`zccache error: unknown session: <uuid>` and the build dies.

The Windows wrapper path now self-heals: it tees zccache's stderr while
the child runs, scans for the `unknown session:` marker on failure,
allocates a fresh session via `zccache session-start`, and retries the
wrapper invocation exactly once with the new session id. On the retry's
own failure the exit code is propagated unchanged.

The Unix exec() path is intentionally left alone — once exec() replaces
the wrapper process there is nowhere left to observe stderr or retry.
A TODO references the issue for the future port. The original symptom
in #265 is Windows-only.

Refs forge-ci/zccache#166, forge-ci/zccache#167, forge-ci/zccache#168.
Partially addresses #265 (Windows; integration test deferred).

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
zackees added a commit that referenced this pull request May 11, 2026
Patch bump covering everything merged since v1.4.0:

- fix(daemon,ci): tolerate unknown sessions and stop killing soldr's
  daemon (#168, closes #166 + #167)
- feat(cli): expose session_end_idempotent for all daemon callers (#163)
- fix(daemon): deterministic flush primitive for event log (#162)
- feat(cli,daemon): relocate daemon exe to global runtime-binaries dir (#158)
- fix(depgraph): normalize workspace-path inputs out of rustc cache key (#160)
- perf(ci): trim platform Test, drop --all-targets from Check, split
  Test/Check jobs (#161, #164, #165)
- chore(ci): drop invalid target-cache-paths from build-target action (#157)

Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees deleted the fix/daemon-session-and-zccache-ci-conflict branch November 5, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant