Repository navigation
fix(daemon,cli): tell slow-under-load apart from hung; queue deploys for a busy port - #2143
Merged
Merged
Conversation
…for a busy port Three failures seen on a host at load ~250 (16 cores at times >1000): 1. Self-eviction mid-build. OperationGuard cleared the shared operation_in_progress flag on every drop, so when one of two concurrent operations finished the idle loop saw an "empty" daemon, self-evicted while the other client was still compiling, and that client failed after ~535 s with "error sending request for url .../api/deploy". The flag now clears only when the last operation drops, busy_reason() also counts active/admitted operations, and self-eviction closes admission atomically (try_begin_shutdown) before shutting down. 2. Fixed wall-clock request caps. Long daemon requests (deploy, build, test-emu, install-deps, streaming build) carried a 30 min reqwest deadline. They now wait on a progress-based watchdog in the soldr style (measure silence, not elapsed time): the daemon exposes a progress_seq counter on /api/daemon/info, bumped by every work tracing event (housekeeping such as the idle loop's "staying alive" is excluded so a hang still looks like a hang) and by operation start/finish. The CLI keeps waiting while it advances and fails only after a stall window (default 600 s, FBUILD_DAEMON_STALL_SECS) scaled by load average per CPU (clamped 1x..16x), naming the stalled stage. A daemon without the counter keeps the old 30 min cap. 3. Busy port failed instantly. A deploy whose port another request's deploy/reset held failed with "port ... is in use" and threw away a finished ~500 s build. It now queues for the port up to 900 s (FBUILD_DEPLOY_PORT_WAIT_SECS), woken as soon as the holder releases, and publishes "waiting for <port>: <holder>" as the daemon's current operation, which the CLI prints.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Fold the atomic self-eviction re-check into the existing condition.
Moves the load-average probe out of fbuild-cli into the platform facade (getloadavg on Linux/macOS, None on Windows) so it stays behind the platform boundary, and gives the liveness probe the medium HTTP timeout so a daemon slowed by host load is not counted as unreachable.
This was referenced Nov 22, 2026
build(deps): require fbuild>=2.5.53 so the daemon stops self-evicting mid-build
FastLED/FastLED#5410
Merged
zackees
added a commit
that referenced
this pull request
Nov 22, 2026
…ain lacks #2143 landed the core self-eviction fix on main (busy_reason counts the drain counter, self-eviction commits with try_begin_shutdown), so this branch's overlapping rewrite conflicted with it. Resolution keeps main's busy_reason and adds what main still lacked: - the eviction window predicate moves into entry/self_eviction.rs as try_self_evict(ctx, &mut empty_since, now, timeout), unit-tested with explicit instants instead of sleeping; mod.rs was at exactly the 1000-LOC gate, so the predicate cannot stay inline; - the 12-hour fallback now requires is_empty() and closes operation admission (try_begin_shutdown) before signalling shutdown, so the fallback cannot kill a daemon that is still building; - a busy tick calls touch_activity(), so the fallback idle clock follows real work rather than wall time. Verified: soldr cargo test -p fbuild-daemon --lib -> 339 passed, 0 failed, 3 ignored (includes the two self-eviction tests through the real loop helper); soldr cargo clippy -p fbuild-daemon --lib --tests -D warnings -> exit 0; cargo fmt --check clean; enforce_platform_boundary rows=0 rc 0. mod.rs 995 LOC, self_eviction.rs 141 LOC.
sutaburosu
pushed a commit
to sutaburosu/FastLED
that referenced
this pull request
Nov 22, 2026
… mid-build (FastLED#5410) fbuild 2.5.52 cleared its shared operation-in-progress flag whenever any operation finished, so with two concurrent builds the daemon self-evicted 30 s after the first one ended. The evicting daemon kept root-owner.lock while draining, new clients timed out spawning replacements, and the eventual SIGTERM killed in-flight builds and dropped device leases. FastLED/fbuild#2143 (v2.5.53) counts active operations instead. Verified locally: a 203 s build with an 11 s build finishing inside it kept the 2.5.53 daemon alive until the long build completed.
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.
Problem
On a heavily loaded host (load ~250-1100 on 16 cores, several agents building concurrently), FastLED's
fbuild deploy -e esp32c6failed in two ways:daemon error: request failed: error sending request for url (http://127.0.0.1:24318/api/deploy).serial error: port /dev/ttyACM1 is in use: deploy (project ...) by request ... for 35s, which threw the build away.Root causes (from
~/.fbuild/prod/daemon/daemon.log)OperationGuard::dropstoredfalseinto the sharedoperation_in_progressflag on every drop. With two concurrent operations, the first one to finish cleared it, and the idle loop loggedDaemon is idle; self-eviction in 30swhile[20/36] compiled [fastled]was still running, thenSelf-eviction triggered. The listener closed, new CLIs spawned daemons that hitroot-owner.lock busy, the old daemon was SIGTERMed within_flight=1, and the surviving client's request died.preempt_for_deployfailed as soon as another request held the port.Fix
OperationGuardclears the flag/state only when the last concurrent operation drops.busy_reason()also counts active and admitted operations. Self-eviction now goes throughtry_begin_shutdown(false), which closes admission atomically with the final busy check./api/daemon/infogainsprogress_seq. It is bumped by every work tracing event (compile steps, library builds, installs, deploy/flash, zccache compile handling) and by operation start/finish. Daemon housekeeping is excluded (the idle loop's once-a-minutestaying alive, health, shutdown, zccache maintenance), so a hang still looks like a hang. The CLI (deploy,build,build_streaming,test-emu,install-deps) samples it every 10 s. It keeps waiting while the counter advances and fails only after a stall window of 600 s (FBUILD_DAEMON_STALL_SECS), scaled by load average per CPU and clamped to 1x-16x. The error names the stalled stage. A daemon without the counter keeps the old 30 min cap. The transport ceiling is 24 h, only to guard against a lost socket.FBUILD_DEPLOY_PORT_WAIT_SECS;0restores fail-fast). ANotifywakes it as soon as the holder releases. While it waits,current_operationreadswaiting for <port> (Ns so far): port ... is in use: deploy (project ...) by request ..., and the CLI prints each stage change.Tests (RED against
main, GREEN here)finishing_one_operation_keeps_daemon_busy_while_another_runs: onmain,busy_reason()isNoneafter the first of two guards drops.slow_but_progressing_operation_outlasts_old_fixed_timeout: a paused-clock run of 2x the old 30 min cap succeeds.stalled_operation_fails_with_clear_error_naming_stage: fails about one stall window after the last progress, and the error names the stage.high_load_extends_the_stall_window,stage_changes_are_reported,legacy_daemon_without_counter_uses_the_old_ceiling.busy_port_is_waited_on_then_acquired,busy_port_wait_is_bounded_and_names_the_holder(tracker),deploy_waits_for_busy_port_then_acquires_it(serial manager).housekeeping_events_do_not_count_as_progress,note_progress_advances_the_counter.Release
Also bumps the version to 2.5.53 (Cargo.toml, pyproject.toml, Cargo.lock, uv.lock) so
release-auto.ymlcan be dispatched on the merge commit.