Skip to content

Retry a client that fails on the database at start, instead of dropping it - #742

Merged
abeldantas merged 2 commits into
mainfrom
fix/client-start-retry
Oct 9, 2026
Merged

abeldantas merged 2 commits into
mainfrom
fix/client-start-retry

Conversation

@abeldantas

@abeldantas abeldantas commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

At boot every client starts at once, and each asks for a database connection, this drains the db the pool.

The cause is _run_client: any exception from consumer.start() logged "crashed" and removed the client, and nothing ever started it again.

Not in this PR: limiting how many clients start at once. consumer.start() runs the client for its whole life, so a semaphore around it would cap how many clients exist. I will send that in a separate PR.

Copilot AI lite review requested due to automatic review settings October 9, 2026 11:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@abeldantas
abeldantas force-pushed the fix/client-start-retry branch from 632c934 to 31a9bad Compare October 9, 2026 12:28
abeldantas added a commit that referenced this pull request Oct 9, 2026
@abeldantas
abeldantas force-pushed the fix/client-start-retry branch from 31a9bad to b1fa6ec Compare October 9, 2026 12:53
…ng it

At boot every client starts at once and asks for a connection in the same
second. On the 9 Oct pilot restart that drained the pool: 13 clients timed
out waiting for a connection and were dropped for good, so their agents
connected but nothing on the server could post for them until the next
restart. A database or network failure says nothing about the client, so it
now waits (1 s, doubling, capped at 60 s) and tries again. Any other error
still ends the client, as before.
…together

The pool drained because every client asked for a connection in the same
second. A deterministic backoff keeps that cohort synchronized: the 13
clients that timed out together would all retry at 1s, then 2s, then 4s,
hitting the pool in the same waves that drained it. Each client now draws
its delay uniformly from [0, cap], which spreads the cohort out.

Claude-Session: https://claude.ai/code/session_01AbWGiYa9zvgoLevkdFwG6M
@abeldantas
abeldantas force-pushed the fix/client-start-retry branch from b1fa6ec to b068e39 Compare October 9, 2026 13:02
@abeldantas
abeldantas merged commit 3363cdc into main Oct 9, 2026
11 checks passed
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.

3 participants