Repository navigation
v5.16.0
Nuthatch 5.16.0 adds writer failover (RFC-0078): a standby that takes over a dataset when its writer
dies, without an operator. It is off unless a mount's publish configuration asks for it, and a runtime
that does not is the runtime 5.15.0 was. There is no storage migration, and no NID, registry hash or
sealed segment changes. Upgrade followers before writers (below): the feed carries two new ops.
Writer failover
Every host runs nuthatch dev over the same mounts.toml, publishing to one mirror:
[runtime.publish]
target = "s3://bucket/prefix"
followers = true
[runtime.publish.failover]
term = "10s"
standby = true
follow = "http://writer.internal:8288" # optional
registry = "s3://bucket/registry" # with followThe writer holds a lease at <data_identity>/lease.json in the mirror and renews it a third of a
term at a time. Every change to it is a conditional put on the bytes last seen, so two hosts racing
for one lease produce one holder. A standby takes it once it has gone unrenewed for the term and half
again, measured on the standby's own clock: no two hosts' clocks are ever compared.
- A writer that loses its lease stops. Its store is fenced off, so its next commit fails; the
nest is quarantined with the reason on/<route>/ready; its publisher stops; and the catalogue is
not moved while the mirror's lease names another fence. A follower that has followed the new writer
refuses the old one, by the fence on each feedmountline. - Taking over, cold. A standby with no copy seeds an empty dataset from the mirror's seed snapshot
and replays the unsealed gap from the chain. - Taking over, warm. A standby with
followfollows the writer while it waits and, on taking the
lease, installs that copy as its store: rows, catalogue and verified segments from one generation.
It resumes from the next block with nothing to replay. - A writer that took over from behind holds its catalogue until every table is sealed through the
mirror's, so the mirror's history never goes backwards. - Webhooks survive a takeover: the outbox travels on the feed, so a promoted standby delivers what
the old writer had not. Delivery across a takeover is at least once. - A planned move is
POST /_admin/failover/handover: the writer stops committing, waits for the
mirror to hold what it sealed, and releases the lease, which a standby takes at once. - Metrics, per nest with failover on:
nuthatch_lease_fence,nuthatch_lease_held,
nuthatch_lease_renewals_total,nuthatch_lease_renew_failures_total. serve --follow --mirror ... --standbyreports each dataset's lease on/readyfrom a follower,
and takes nothing.
docs/operators.md has the whole of it under "Failover".
Measured by scripts/failover-gate.sh, new and run in CI as failover: two to five dev
processes over a fixture chain and one mirror, at a 3-second term, on a MacBook. A second writer is
refused while the first renews. A writer frozen with SIGSTOP is taken over, and on waking stops by
itself. From SIGKILL of the writer to the standby's first full answer: 5 to 6 s cold, 5 s warm.
A planned handover: 1 to 2 s from the request. At the default 10-second term a crash costs about
16 s. a_promoted_follower_ends_where_an_uninterrupted_writer_does cuts a writer while every row is
hot, after a reorg and after a seal, and in each the promoted writer ends with the rows of one never
interrupted.
Limits
- The mirror must refuse a stale conditional write, or there is no lease. versitygw, which CI
runs, does; Garage and Zenko CloudServer accept one. Run
tests/e2e_minio_publish.rs::the_store_enforces_conditional_writesagainst your store first. - A waiting standby serves nothing until it takes the lease, so a load balancer sees it as down.
Serve reads from followers. - Failover is taken at boot. A mount added to a running runtime whose mirror asks for failover
is refused with "restart the runtime"; put it inmounts.tomland restart. - The parity run covers an ERC-20 nest at three chosen points; a factory nest's child registry is
rebuilt from stored events on promotion, which is reasoned and not yet run.
For a runtime without failover
Nothing to do, and these are the only differences:
- A store whose ownership another holder has claimed (
LostOwnership) is now a terminal fault for
the nest on it, quarantined until restart, where it was retried on a backoff that failed the same
way each time. This reaches scaled mode's workers too. - A conditional put the mirror refuses is reported as its own error type; the messages are as they
were. - The feed carries alert-outbox enqueues and deliveries as ops, and snapshots carry the outbox, so
a follower holds it beside the rows and is charged for it.
Three RFCs are accepted and not built: RFC-0079 (Arrow results: /sql in Arrow IPC, Flight SQL
behind a feature), RFC-0080 (partial sync for the embeddable engine), and RFC-0081 (the engine in
use).
Compatibility and upgrade
Replace the binary and restart. A 5.15 store is used as it is, and no NID, registry hash or sealed
segment changes.
Upgrade followers before writers. A 5.16 writer sends two ops, outbox and unoutbox, that a
5.15 follower cannot read, and it sends them whenever an alert is enqueued or delivered. A 5.16
follower reads a 5.15 writer. This is the order the rolling-upgrade procedure in
docs/operators.md already takes, and scripts/rolling-upgrade.sh gates it.