Daemon resilience: over-cap connection evicts a healthy daemon (SIGKILL); corrupt index dead-ends; rm -rf of a large dir stalls indexing for minutes; rollback exits 0 while deferred #382

Closed
opened 2026-10-15 15:37:48 +02:00 by buildagent · 1 comment
Member

Found by the 2026-10-15 review on 0.39.0. All of these are pre-existing. Related: #358, whose idle_timeout_min key is written by init and never read.

  1. Over-cap connections evict a healthy daemon. At 64 connections, a further client's probe gets no reply. Over-cap connections are closed silently (daemon/src/server.rs ~212), and takeover_decision returns EvictThenAcquire after a 2 s probe, so the healthy daemon is SIGKILLed. Executed in the review. Fix: answer over-cap connections with a busy frame, and never evict when a probe saw a full cap.
  2. A corrupt index.db is a dead end.
    • The client is told warming_up … succeed automatically for 60 s while the daemon dies about 0.1 s after each spawn, because the spawn poll never checks whether the child exited.
    • doctor reports FAIL but gives no remedy.
    • Since #374 the database is a cache: reset it in place on SQLITE_CORRUPT/NOTADB (reusing the #374 reset), and report the exit cause on spawn.
  3. rm -rf of a large directory stalls indexing. notify-debouncer-full keeps a file-id cache whose removal scan is quadratic: 10k files take about 410 s, and 60k take more than 12 min and then overflow the queue. Fix: NoCache on Linux.
  4. plugin rollback succeeds without doing anything. While a daemon runs it is deferred and does nothing, but exits 0. Fix: a non-zero exit, or a request the daemon acts on.
  5. Approval and trust-store writes are not atomic. They delete the target before the rename and never fsync. A poll in that window reads "no approvals", and a crash there wipes them.
  6. daemon.lock is unlinked before the kernel lock is released, so two daemons can each own the root for a moment.
Found by the 2026-10-15 review on 0.39.0. All of these are pre-existing. Related: #358, whose `idle_timeout_min` key is written by `init` and never read. 1. **Over-cap connections evict a healthy daemon.** At 64 connections, a further client's probe gets no reply. Over-cap connections are closed silently (`daemon/src/server.rs` ~212), and `takeover_decision` returns `EvictThenAcquire` after a 2 s probe, so the healthy daemon is SIGKILLed. Executed in the review. Fix: answer over-cap connections with a `busy` frame, and never evict when a probe saw a full cap. 2. **A corrupt `index.db` is a dead end.** - The client is told `warming_up … succeed automatically` for 60 s while the daemon dies about 0.1 s after each spawn, because the spawn poll never checks whether the child exited. - `doctor` reports FAIL but gives no remedy. - Since #374 the database is a cache: reset it in place on SQLITE_CORRUPT/NOTADB (reusing the #374 reset), and report the exit cause on spawn. 3. **`rm -rf` of a large directory stalls indexing.** notify-debouncer-full keeps a file-id cache whose removal scan is quadratic: 10k files take about 410 s, and 60k take more than 12 min and then overflow the queue. Fix: `NoCache` on Linux. 4. **`plugin rollback` succeeds without doing anything.** While a daemon runs it is deferred and does nothing, but exits 0. Fix: a non-zero exit, or a request the daemon acts on. 5. **Approval and trust-store writes are not atomic.** They delete the target before the rename and never fsync. A poll in that window reads "no approvals", and a crash there wipes them. 6. **`daemon.lock` is unlinked before the kernel lock is released**, so two daemons can each own the root for a moment.
Author
Member

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): a daemon at its connection cap answers "busy" and is never evicted by a takeover; a client waiting on a daemon it spawned stops when that daemon exits and reports why; daemon.lock survives shutdown so a released project has one next owner; a damaged index in its own state directory is reset and rebuilt; mass deletes no longer stall the debouncer.

Released in v0.40.0 (https://git.h-dv.de/h-dv/code-index/releases/tag/v0.40.0, PR #388, merge a48fb945): a daemon at its connection cap answers "busy" and is never evicted by a takeover; a client waiting on a daemon it spawned stops when that daemon exits and reports why; `daemon.lock` survives shutdown so a released project has one next owner; a damaged index in its own state directory is reset and rebuilt; mass deletes no longer stall the debouncer.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
h-dv/code-index#382
No description provided.