Skip to content

feat(connection): watch connections, and show what the pool is doing - #660

Merged
EVWorth merged 1 commit into
mainfrom
feat/connection-health
Sep 12, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/connection-health

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Closes #276, #279.

The tab looked fine until the next query failed

ARCHITECTURE §3.1 described a HealthChecker emitting connection_lost, and nothing emitted it. A connection whose server had gone looked exactly like a healthy one until someone ran a statement and got "Connection not found" — which says neither what happened nor when.

There is one now: one task per connection, SELECT 1 every 15 seconds, backing off to FR-1.2.4's schedule — 1s, 2s, 4s, 8s, 16s, then 30s — from the first failed ping until one succeeds. The status bar turns its dot red, says "Lost — retrying (3)", and carries the server's own words in the title.

Two decisions worth naming:

  • No explicit reconnect step. sqlx opens a fresh pooled connection when one is next asked for, so a server that comes back is usable again without anything being torn down or re-established. The checker's job is to say what is happening, not to rebuild what does not need rebuilding.
  • No jitter, despite the doc's + jitter(0–500ms). Jitter exists to stop a thousand clients retrying in lockstep. A desktop client with a handful of connections has no herd to disperse, and the doc now says so instead.

The task ends when the connection is removed from the manager, because the stop channel is owned by the entry — no second registry to fall out of step with reality.

Pool statistics in the status bar (#279)

FR-1.2.3 asked for them and there were none. It shows pool 3/5, amber when nothing is free, with a title saying what that means for the next query. Polled every three seconds rather than pushed: it changes with every query and nobody needs to know within the second.

The error message half of #279 was already fixed — a pool timeout names the profile, the limit and what to change.

The pool fields took any number at all

A max of zero (sqlx panics), a min above the max (sqlx refuses to build the pool), a five thousand that would open five thousand server threads. The dialog now says why, beside the field, with aria-invalid and a disabled Save. The backend clamps to 1–50 as well, so a profile stored by an older build still connects rather than failing later at a number nobody can see — with a warning in the log saying it did.

Tests

+18 Rust (5 live-server, passing on MySQL 8.0.46 and MariaDB 11.8), +19 frontend. 2750 unit, 344 browser.

One fix in passing. The command-contract test sliced the generated bindings at the first \n} — which an inline object type, what specta writes for an Option<Struct>, puts in the middle. Every command after that point was silently dropped from the check, which is how a contract test stops being one.

ARCHITECTURE described a HealthChecker emitting connection_lost, and
nothing emitted it. A tab whose server had gone looked exactly like one
whose server was fine, right up until the next query failed with
"Connection not found" — which says neither what happened nor when.

There is one now: a task per connection pinging every 15 seconds, and
backing off to FR-1.2.4's schedule — 1s, 2s, 4s, 8s, 16s, then 30s —
from the first failure until one succeeds. The status bar turns its dot
red, says "Lost — retrying (3)" and carries the server's own words in
the title. Nothing is torn down in between: sqlx opens a fresh pooled
connection when one is next asked for, so a server that comes back is
usable again without the user doing anything.

No jitter, deliberately. It exists to stop a thousand clients retrying
in lockstep; a desktop client with a handful of connections has no herd
to disperse.

The task ends when the connection is removed from the manager, because
the stop channel is owned by the entry — there is no second registry to
keep in step.

FR-1.2.3 also asked for pool statistics in the status bar. It shows
`pool 3/5` now, amber when nothing is free, with a title saying what
that means for the next query.

And the pool fields took any number at all: a max of zero, which makes
sqlx panic; a min above the max, which makes it refuse to build the
pool; a five thousand that would open five thousand server threads. The
dialog now says why, beside the field, and will not save. The backend
clamps as well, so a profile stored by an older build still connects
rather than failing at a number nobody can see.

+18 Rust tests (5 live-server, on MySQL 8.0.46 and MariaDB 11.8), +19
frontend tests.

One fix in passing: the command-contract test sliced the generated
bindings at the first `\n}`, which an inline object type — what specta
writes for an `Option<Struct>` — put in the middle, silently dropping
every command after it from the check.
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.

[P1][bug] auto-reconnect on launch is a single-shot try/catch; no backoff, no surface, no HealthChecker (FR-1.2.4 / ARCHITECTURE §3.1 HealthChecker)

1 participant