Skip to content

fix(host): raise the fd budget at startup and report it on store failures - #1687

Merged
huichen merged 1 commit into
mainfrom
pr/huichen
Nov 24, 2026
Merged

huichen merged 1 commit into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

The Desktop and future host entry points now raise the process descriptor budget before opening any store or session, and a failed store open reports the descriptor count, the soft/hard limit and the SQLite code — so descriptor exhaustion is distinguishable from a broken database.

Commits

  • fix(host): raise the fd budget at startup and report it on store failures — adds the future-fd crate (one production copy of the raise: upward-only soft limit to min(8192, hard), idempotent, never fatal, plus the descriptor probe and the fields a failed open carries), calls it from environment::prepare_process_for before the first database open, records the resulting budget in start_logging, and puts fds=<n> limit=<soft>/<hard> code=<n> on failed app-store opens and Agent event-journal storage failures.

Verification

Local, toolchain 1.99.1 (the repo pin), ulimit -n 8192, at branch head de0373626:

  • cargo fmt --all -- --check → pass
  • cargo clippy -p future-fd -p future-host -p future-agent --all-targets -- -D warnings → pass
  • cargo test -p future-fd --lib → 5 passed
  • cargo test -p future-host --lib → 2350 passed, 15 ignored
  • cargo test -p future-agent --lib → 3142 passed, 7 ignored

Notes

  • New workspace crate future-fd (packages/fd).
  • The raise is upward-only: a lower hard limit is respected and the inherited soft limit is kept; a refused raise is logged as a warning, never fatal.
  • The Agent's event batch commit failed message now carries the same descriptor/SQLite detail.

User-visible changes

  • Descriptor budget: before, a Desktop launched from Finder or launchd inherited a soft RLIMIT_NOFILE of 256 for a process that serves every session (measured 185 descriptors, 44 of them SQLite, on a 14 h instance); after, the soft limit is raised to min(8192, hard) at startup, upward only and idempotently. Rollback: revert this PR (branch commit de0373626).
  • Store-failure logs: before, a failed app-store open or event-journal append showed only the error chain; after, the line also carries fds=<n> limit=<soft>/<hard> code=<n>, and the launch records its fd budget: line. Rollback: same commit.

…ures

A Desktop launched by Finder or launchd inherits a soft RLIMIT_NOFILE of
256, and that one process serves every session: measured 2026-11-25 on the
running app (pid 90103, 14 h up), 185 descriptors with 44 of them SQLite
(agent.db 22, app.db 13, tasks.db 5) — 72 % of the ceiling before any worker
burst. Nothing raised it: grep for RLIMIT_NOFILE/setrlimit under desktop/
found nothing, while the TUI has had a production raise (tui/src/lib.rs:141)
and the Agent's copy is #[cfg(test)].

- packages/fd (`future-fd`): one production copy of the raise — soft limit
  to min(WANT=8192, hard), upward only, idempotent, never fatal — plus the
  descriptor-count probe and the fields a failed store open must carry.
- host: `environment::prepare_process_for` raises it before the first store
  or session is opened (the same hook both `futureos` and `future host`
  run), and `start_logging` reports the outcome once the host log exists.
- A failed app-store open now logs `fds=<n> limit=<soft>/<hard> code=<n>`
  with what 13/14 mean; the Agent's event-journal storage failures carry the
  same detail, because the 2026-11-24 10:08:52Z window had SQLITE_FULL (13)
  beside CANTOPEN (14) and the two are indistinguishable without it.

Tests: the raise is proved in a child process (lowered to 256 → 8192; a
second call moves nothing; a 256 hard limit is respected), and both log
lines are pinned — removing the raise or the detail turns them red.
@huichen
huichen enabled auto-merge (squash) November 24, 2026 18:30
@huichen
huichen merged commit befe87b into main Nov 24, 2026
93 of 99 checks passed
@huichen
huichen deleted the pr/huichen branch November 24, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant