Skip to content

Retry session registration instead of killing the daemon - #131

Merged
davidrhodus merged 1 commit into
mainfrom
fix/registration-retry-backoff
Jul 26, 2026
Merged

Retry session registration instead of killing the daemon#131
davidrhodus merged 1 commit into
mainfrom
fix/registration-retry-backoff

Conversation

@davidrhodus

Copy link
Copy Markdown
Contributor

Problem

ensure_registered_now failed on the first error, and the daemon startup path propagates it with ? — so one stalled registration takes the whole daemon down.

This is not an outage-only path. Control-plane writes routinely stall past this client's 10s request timeout under load. Observed live while testing a single turn:

sync: registering session at .../hi/sessions: operation timed out
sync events: flushing live events to .../events: operation timed out
sync: acquiring session lease at .../lease: operation timed out

The knock-on cost is worse than a lost daemon: the next start derives a fresh session id from a fresh session file, so every death also strands an empty session in the user's catalog. One machine accumulated 23 sessions in 3.3 hours, 21 of them empty.

Change

Retry registration up to 5 times with exponential backoff (2s, doubling, capped at 30s), reporting recovery when a later attempt succeeds. The per-flush registration path is untouched — it already retries naturally on the next flush.

This is the client-side half. The server-side half (hi writes currently ride a full control-plane store save) is tracked separately.

Tests

cargo test -p hi --bins — 186 passed.

🤖 Generated with Claude Code

`ensure_registered_now` failed on the first error, and the daemon startup
path propagates that with `?` — so a single stalled registration takes
the whole daemon down. Control-plane writes routinely stall past this
client's 10s request timeout under load, so this fires in normal
operation, not just during outages.

The cost is worse than a lost daemon: the next start derives a fresh
session id from a fresh session file, so every death also strands an
empty session in the user's catalog. One machine accumulated 23 sessions
in 3.3 hours, 21 of them empty.

Retry up to 5 times with exponential backoff (2s, capped at 30s), and
report the recovery when a later attempt succeeds. The per-flush
registration path is unchanged — it already retries on the next flush.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@davidrhodus
davidrhodus merged commit 95cd3dc into main Jul 26, 2026
1 check failed
@davidrhodus
davidrhodus deleted the fix/registration-retry-backoff branch July 26, 2026 01:49
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