Skip to content

fix(cli): adopt same-version cache-root owner daemon; fail fast on a foreign owner - #1739

Open
zackees wants to merge 4 commits into
mainfrom
fix/daemon-root-owner-adoption
Open

zackees wants to merge 4 commits into
mainfrom
fix/daemon-root-owner-adoption

Conversation

@zackees

@zackees zackees commented Oct 25, 2026

Copy link
Copy Markdown
Member

Problem

A fbuild deploy failed twice (~65 s each) with daemon did not become healthy after 3 spawn attempts while fbuild daemon status showed a healthy daemon on port 60903 busy building another project.

Root cause (from ~/.fbuild/prod/daemon/daemon.log)

Not a slow /health. Both clients reported 2.5.44, but one was a PyPI wheel built before the #1700 port-window change (default port 60903, binds 0.0.0.0) and the other a dev build after it (default port 19142). The CLI polled 19142, found nothing, and spawned daemons that each logged fatal: another fbuild-daemon owns the cache root (root-owner.lock busy) and exited. After three spawns it reported the busy owner as unhealthy. fbuild daemon subcommands already route through root-owner.json, which is why status showed the owner while build/deploy did not.

Fix

  • fbuild_paths::get_daemon_port: after the endpoint port file, use the port in root-owner.json when the claim's pid is a live fbuild-daemon and its version, mode and cache root match ours (pure helper adoptable_owner_port, unit-tested).
  • ensure_direct_daemon_running: if a live owner of another version or identity holds the cache root on a different port, fail at once with its pid, version, port and exe instead of spawning daemons that cannot start.

Evidence

  • soldr cargo test -p fbuild-paths --lib owner: 13 passed (2 new)
  • soldr cargo test -p fbuild-cli --bin fbuild foreign_root_owner: 1 passed (new)
  • clippy -D warnings is clean on both crates
  • End to end on Linux: with the fastled2 2.5.44 wheel daemon owning the cache root, target/debug/fbuild build tests/platform/uno -e uno (2.5.45) now fails in 0.09 s with the fbuild cache root is owned by another fbuild-daemon (pid 522668, version 2.5.44, mode prod, port 60903, exe .../fastled2/.venv/bin/fbuild-daemon) .... Before, it took about 34-65 s and ended with the generic unhealthy-daemon error.
  • I did not reproduce the same-version adoption path end to end, because that needs two differently built binaries with the same version string. The unit tests cover it.

Follow-up: same-version builds with different port derivation can still evict each other through the mtime restart check when the owner is idle. This was already true before this change.

…l fast on a foreign owner

Two fbuild builds that both report 2.5.44 derived different daemon ports
(a wheel built before the #1700 port-window change: 60903; a dev build
after it: 19142). The version-blind root-owner lock lets only one daemon
run, so while the wheel's daemon was busy building, the dev CLI spawned
three daemons that each exited with 'root-owner.lock busy' and then
reported 'daemon did not become healthy after 3 spawn attempts' (~65 s).
'fbuild daemon status' already followed root-owner.json, so it showed
the busy owner, while build/deploy did not.

- get_daemon_port: after the endpoint port file, use the live owner
  claim's port when version, mode and cache root match.
- ensure_direct_daemon_running: when a live owner of another
  version/identity holds the cache root on a different port, fail at
  once naming its pid/version/port/exe instead of doomed respawns.
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 8c27718 and e772a41.

Files selected for processing: 4
  • crates/fbuild-cli/src/daemon_client.rs
  • crates/fbuild-cli/src/daemon_client/tests.rs
  • crates/fbuild-paths/src/lib.rs
  • crates/fbuild-paths/src/owner_port_tests.rs
  • 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

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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