Repository navigation
fix(daemon): upgrade zccache, flush on exit, and wait on a starting daemon (#1480) - #1482
Merged
Merged
Conversation
|
Warning Review limit reachedNext included review available in 18 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: FastLED/fbuild/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (14)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
zackees
added a commit
that referenced
this pull request
Sep 26, 2026
…ck-starting daemon (#1480) Review follow-ups on #1482: - Exit flush timeout 30 s -> 4 s (a normal flush takes <100 ms). Stays under `fbuild daemon stop`'s 5 s graceful budget and the 10 s a replacement daemon waits for the root-ownership lock, so a slow flush never escalates a stop to a kill or fails a restart spawn. - CLI: a daemon still `starting` when the wait ends is reported as stuck (with its phase and the daemon log path) instead of being respawned, which only queued more 120 s waits behind it. - daemon_health::probe/wait_until_healthy take the per-request timeout, so the PyO3 client keeps its previous 5 s /health timeout.
…aemon (#1480) - Repin zccache to main 3f9d4e6, which carries forge-ci/zccache#1710: embedded depgraph load after readiness (the silent 12-47 s bring-up in #1462), timed bring-up phases, and a periodic metadata.bin snapshot. - Flush the embedded zccache backend before the daemon exits, bounded at 4 s (a normal flush takes <100 ms): under `fbuild daemon stop`'s 5 s graceful budget and the 10 s a replacement daemon waits for the root lock. process::exit runs no destructors and the backend lives in a OnceLock, so metadata.bin was never written and every start was cold. - Serve `503 {"status":"starting","phase":...}` on every route from bind until the full router takes over (fbuild-daemon::startup::StartupGate, a duplicate of the bound listener sharing its accept queue). - Shared fbuild_core::daemon_health: probe/classify, a ReadinessDeadline that stretches while the daemon reports `starting` (cap 120 s), and wait_until_healthy. The CLI and PyO3 clients use it for every readiness wait and wait on a starting daemon instead of spawning a duplicate; the CLI reports a daemon still `starting` at the cap as stuck (with its phase) rather than respawning behind it. Closes #1480. Closes #1462.
zackees
force-pushed
the
fix/1480-zccache-upgrade-daemon-startup
branch
from
September 26, 2026 16:38
245290b to
5c94271
Compare
zackees
added a commit
that referenced
this pull request
Sep 26, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 26, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 26, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 27, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 27, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 27, 2026
…lush
Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation
in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with
no zccache flush and stale pid/port files. Routing it through the graceful
HTTP drain would instead wait out every running build.
- New fbuild_daemon::shutdown:
- refuse_new_operations_when_shutting_down: operation routes (build,
deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed
OperationResponse once shutdown has started (SIGTERM or HTTP shutdown).
- exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for
in-flight operations, flush zccache (4 s cap), clean up records, exit.
- persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush
now shared by every clean exit.
- DaemonContext::active_operations: exact in-flight count kept by
OperationGuard (the operation_in_progress bool is cleared by the first of
two concurrent operations to finish), plus wait_for_operations(budget).
- fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET
(4 s), TERMINATE_EXIT_BUDGET (their sum).
- `fbuild daemon stop`: after a delivered graceful terminate, wait
TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands
mid-flush; a refused terminate keeps the 5 s wait.
Follow-up to #1480 / #1482.
zackees
added a commit
that referenced
this pull request
Sep 27, 2026
…lush (#1486) * fix(daemon): controlled exit on SIGTERM — gate new work, drain 5 s, flush Before this, SIGTERM on Linux/macOS (`fbuild daemon kill`, the escalation in `fbuild daemon stop`, docker stop, CI teardown) killed the daemon with no zccache flush and stale pid/port files. Routing it through the graceful HTTP drain would instead wait out every running build. - New fbuild_daemon::shutdown: - refuse_new_operations_when_shutting_down: operation routes (build, deploy, monitor, install-deps, reset, test-emu) answer 503 with a failed OperationResponse once shutdown has started (SIGTERM or HTTP shutdown). - exit_on_terminate: on SIGTERM, refuse new work, wait up to 5 s for in-flight operations, flush zccache (4 s cap), clean up records, exit. - persist_and_clean_up: the pid/port/claim/status cleanup + bounded flush now shared by every clean exit. - DaemonContext::active_operations: exact in-flight count kept by OperationGuard (the operation_in_progress bool is cleared by the first of two concurrent operations to finish), plus wait_for_operations(budget). - fbuild_core::daemon_health: SHUTDOWN_DRAIN_BUDGET (5 s), EXIT_FLUSH_BUDGET (4 s), TERMINATE_EXIT_BUDGET (their sum). - `fbuild daemon stop`: after a delivered graceful terminate, wait TERMINATE_EXIT_BUDGET + 1 s before the forced kill so it never lands mid-flush; a refused terminate keeps the 5 s wait. Follow-up to #1480 / #1482. * fix(daemon): move SIGTERM listener into the platform layer The platform boundary forbids #[cfg(unix)] outside fbuild_core::platform. Add fbuild_core::platform::process::daemon_terminate_signal() (tokio SIGTERM on Linux/macOS, never resolves on Windows, whose termination requests already arrive via register_daemon_shutdown_handler) and use it from the daemon. Regenerate ci/platform_boundary_research.tsv for the shifted windows/process.rs rows. * fix(daemon): synchronize shutdown admission * fix(daemon): keep termination policy behind platform facade * fix(daemon): test shutdown admission and refresh boundary inventories * fix(paths): keep executable memo identity behind platform boundary * Refresh platform boundary inventory after rebase * fix(daemon): keep SIGTERM process exit in binary entry point
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 #1480. Closes #1462.
Summary
Three changes so a slow daemon start is no longer reported as a failed build (#1462), and zccache stops starting cold after every daemon restart.
1. Upgrade zccache to main
3f9d4e6Repins zccache in all five crates that use it, from
126380bto3f9d4e6(current zccache main). The new pin includes forge-ci/zccache#1710, which fixes forge-ci/zccache#1652:CompileBackend::startnow returns in well under a second.metadata.binis saved periodically.Other version constraints are unchanged:
running-processstays at=4.10.14from crates.io, which is what zccache resolves.zccache/v1.14.14/) does not change and upgrading does not force a cold cache.2. Flush the embedded backend when the daemon exits
The daemon ends with
std::process::exit(0), and the backend lives in aOnceLock, so zccache's flush, shutdown and drop paths never ran. That is whymetadata.binwas missing on every start. The daemon now callsflush()on the backend before exiting, capped at 4 s. A normal flush takes under 100 ms. The cap keeps it belowfbuild daemon stop's 5 s graceful budget and below the 10 s a replacement daemon waits for the root-ownership lock.3. Report
startingon/health, and have clients wait for itfbuild-daemon/src/startup.rs(new,StartupGate): right after bind, the daemon duplicates the listening socket. A minimal responder on the duplicate answers every request with503 {"status":"starting","phase":"usb_overlay|root_ownership|compile_backend",...}. Just beforeaxum::serve, the gate stops the responder and hands the original socket to the full router. Both handles share one accept queue, so a connection that arrives during the hand-over waits in the backlog instead of being refused.fbuild-core/src/daemon_health.rs(new):probe,classify,ReadinessDeadlineandwait_until_healthy, shared by the CLI and the PyO3 bindings. The wait gives up after the base budget (10 s) on an endpoint that never answers. While the daemon reportsstarting, the deadline keeps moving forward, up to a 120 s cap. It never moves earlier, so a daemon that exits during init still fails quickly.fbuild-cli: the spawn-winner poll, the spawn-loser wait and the broker adoption poll all usewait_until_healthy. When the endpoint already reportsstarting, the CLI waits for that daemon instead of spawning a duplicate. After 5 s ofstarting, it prints one line on stderr naming the phase.fbuild-python: the same change forDaemon.ensure_runningandAsyncDaemon.ensure_running.Mixed versions keep working:
503as "not healthy yet", which is what it saw before.starting, so a new client behaves as it did before.Validation
soldr cargo clippy --workspace --all-targets -- -D warnings: clean.bash test: all passing.RUSTDOCFLAGS="-D warnings" soldr cargo doc: clean.fbuild-core::daemon_health: 10 tests. These include a real HTTP server that answersstartingfor about 2 s; the wait succeeds even though the base budget is 300 ms. An unreachable port still gives up after the base budget.fbuild-daemon::startup: 3 tests. The phase is reported on/health, every route answersstarting, and after the hand-over the full router answers healthy on the same port.fbuild-daemonandfbuildbinaries:/healthanswered503 {"status":"starting","phase":"usb_overlay",...}27 ms after launch and moved to200once startup finished.fbuild buildof an uno sketch on a cold daemon succeeded through the new wait path. The log showsdaemon startup phase: root_ownership → compile_backend → daemon startup complete in 0.3s.fbuild daemon stoploggedmetadata cache flushed to disk … metadata.binandzccache backend flushed. The next cold start loggedmetadata cache loaded from diskwhere every earlier start had loggedmetadata cache file not found, starting empty.Review follow-ups (second commit)
startingwhen its wait ends as stuck. It reports an error naming the phase and the daemon log path, instead of respawning and queuing more 120 s waits. New test:wait_on_a_daemon_stuck_starting_ends_at_the_starting_budget.probeandwait_until_healthynow take the per-request timeout as a parameter, so the PyO3 client keeps its previous 5 s/healthtimeout and the CLI keeps 2 s.Known limits (not changed here)
metadata.bin. zccache's flush saves the depgraph before metadata, and first waits for the startup depgraph load to finish. If the daemon shuts down while that load is still running, the 4 s cap can expire beforemetadata.binis written. zccache's periodic snapshot (ci: full / windows / Check hits its 45-min timeout-minutes on routine runs #1710) remains the fallback. Saving metadata before that wait belongs in zccache.