Skip to content

fix(daemon): don't self-evict while operations are in flight - #2144

Merged
zackees merged 2 commits into
mainfrom
fix/daemon-idle-evict-inflight
Nov 22, 2026
Merged

zackees merged 2 commits into
mainfrom
fix/daemon-idle-evict-inflight

Conversation

@zackees

@zackees zackees commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

A running build can lose its daemon connection when another operation clears the legacy operation_in_progress boolean. Self-eviction now checks the same admitted-request and active-operation counters as shutdown, restarts its idle window after activity, and atomically closes operation admission before signaling shutdown. The 12-hour idle fallback also respects active work; explicit stop/SIGTERM behavior is unchanged.

Focused regression tests cover overlapping operation guards (one completes while another is still building), admitted requests before guard creation, a fresh idle window after completion, and refusal of new operations once self-eviction commits to shutdown. The timer uses explicit instants so these tests do not sleep.

Merged up to main after #2143 ("tell slow-under-load apart from hung; queue
deploys for a busy port") landed the same core fix independently — it also
counts the drain counter in busy_reason() and commits self-eviction through
try_begin_shutdown. The merge therefore keeps main's busy_reason() and
keeps only the delta main lacked:

  • the idle-window predicate is extracted to entry/self_eviction.rs as
    try_self_evict(ctx, &mut empty_since, now, timeout) and unit-tested with
    explicit instants (no sleeps). entry/mod.rs sits at exactly the 1000-LOC
    gate on main, so the predicate cannot stay inline; it is 995 LOC now.
  • the 12-hour fallback requires is_empty() and closes operation admission
    (try_begin_shutdown) before signalling shutdown, so it can no longer kill a
    daemon that is still building.
  • a busy tick calls ctx.touch_activity(), so the fallback idle clock follows
    real work rather than wall time.

Validation (in a worktree at the merge commit, all Rust through globally
installed soldr):

  • soldr cargo test -p fbuild-daemon --lib: 339 passed, 0 failed, 3 ignored,
    including entry::self_eviction::tests::self_eviction_waits_for_in_flight_operations_and_a_fresh_idle_window
    and ..._waits_for_admitted_operation_requests (the former drops one of two
    overlapping OperationGuards and asserts no eviction, then asserts the window
    re-arms from the first quiet tick and that admission is closed once it fires).
  • soldr cargo clippy -p fbuild-daemon --lib --tests -- -D warnings: exit 0.
  • soldr cargo fmt --check -p fbuild-daemon: clean.
  • uv run --no-project python ci/enforce_platform_boundary.py --print-totals:
    rows=0; dylint_rows=0, rc 0.
  • Hosted CI on the merge head: 24 checks pass, 9 skipped, 0 failing, 0 pending.

Not covered by a test: the 12-hour branch itself needs a 12-hour clock, so only
its gate (is_empty + try_begin_shutdown) is exercised by review, not a unit
test. The integration suites were not re-run this round (the local --lib suite
plus hosted ci-minimal cover this change); 13 integration tests were green on
the pre-merge commit.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

…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.
@zackees
zackees added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 676287f Nov 22, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant