Skip to content

fix(pump): retry leader and source bootstrap failures - #128

Merged
olavurellefsen merged 3 commits into
mainfrom
fix/retry-leader-bootstrap
Nov 1, 2026
Merged

olavurellefsen merged 3 commits into
mainfrom
fix/retry-leader-bootstrap

Conversation

@olavurellefsen

@olavurellefsen olavurellefsen commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Transient failures during a leader change can leave a live lease with no working source pumps. A source that throws during initial bootstrap also leaves a partially started instance pulsing, and prevents later sources from starting.

The builder retries leader bootstrap while its leadership generation remains current. Each source now stops and discards a partially started pump, retries with capped exponential backoff, and lets healthy peer sources start. Losing leadership or stopping the runtime cancels pending retries. Existing checkpoint factories and cursor positions are preserved.

Verification: full PostgreSQL-backed deno test -A: 102 passed (253 steps), zero failures. Focused initial-source and leadership retry tests: 4 passed (19 steps). deno lint, deno check src/mod.ts, and the npm ESM/CJS build pass. Added an explicit Node process import required by the current Deno linter in an existing Bun regression test.

Production evidence: compute-api and compute-reconciler were independently recovered by rolling their existing versions on 2026-11-01. All seven subscribed sources became live with fresh pulses and empty buffers, without resetting saved checkpoints. This PR is permanent prevention; its release still needs adoption by those applications.

olavurellefsen and others added 3 commits October 6, 2026 21:52
When an instance won the leader lease and registering the virtual pathway
failed (e.g. a 502 from the control plane for longer than the provisioning
retries cover), bootstrapLeaderPump stopped the pump and threw. The error was
only logged, while the cluster manager kept renewing the lease, so no
instance ran a pump until the process restarted.

Retry the bootstrap with backoff (1s, 2s, 5s, 10s, then every 30s) for as
long as this instance is still the current leader. A leadership change bumps
a generation counter so stale retry loops stop.

Seen in production on klokkan: events were written but not delivered for
about five hours.

Co-Authored-By: Claude <noreply@anthropic.com>
@olavurellefsen olavurellefsen changed the title fix(cluster): keep retrying the leader bootstrap while holding the lease fix(pump): retry leader and source bootstrap failures Nov 1, 2026
@olavurellefsen
olavurellefsen merged commit 7c1a5f1 into main Nov 1, 2026
2 checks passed
@olavurellefsen
olavurellefsen deleted the fix/retry-leader-bootstrap branch November 1, 2026 15:31
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