Repository navigation
v5.14.0
Nuthatch 5.14.0 scales the shared runtime: the first three of GraphOps's follow-up requests in
RFC-0076, taken after 5.13.0's shared runtime went in. A chain's gate now seats only the tenants that
are querying, so a thousand mounted tenants cost an idle gate nothing; the nests on one chain progress
independently behind one extraction stage, so a slow nest no longer sets its siblings' pace; and a
follower can serve from another host, reading the mirror and the registry instead of the writer's
disk. The chain still has one cursor, one finality view and one reorg authority. There is no storage
migration: the hot store's tables, the sealed segment format and the segment manifest are unchanged,
the segment-hash pins pass untouched, and no nest's NID, registry hash or sealed segment changes. The
buffered cursor is now the default for a runtime, and that and the other changes an operator will
notice are listed at the end.
Many tenants per chain (FR19)
In 5.13 every tenant with a mount on a chain held one SQL permit whether or not it queried, and a gate
had at most 16 permits, so past that many tenants an idle tenant's reservation blocked an active one.
Now only a tenant with a query queued or running on a gate is seated there, and its fair share is
worked out over the active tenants by weight (#2498). Each gate keeps a reserve of
max(1, sql_permits / 8) permits that only a tenant holding none may take, and a tenant already
holding a permit borrows more only while the reserve stays free, so a newly active tenant finds a
permit within the 250 ms admission wait unless more tenants arrive in that wait than the reserve
holds. That is the bound, and docs/bench/rfc-0076-tenants.md measures it: 1,000 mounted tenants
against 5.13.0's ledger, where heavy borrowers at 64 permits went from 392 to 2,549 queries a second
and the light tenants' p99 wait was 0 ms. The bench measures admission, not real statements.
The permit count is runtime configuration. [runtime] sql_permits in mounts.toml sets it, and
PUT /_admin/runtime {"sql_permits": n} changes every cursor's gate with no restart, written to
the file first. Absent, NUTHATCH_SQL_MAX_CONCURRENCY sets it at boot, and absent too it is 2. The
fixed ceiling of 16 is gone; the ceiling is each cursor's memory split, and a count that does not
fit max_rss_mb is 409. GET /_admin/runtime now reports sql_permits, sql_permits_default,
session_cache_capacity, and per cursor sql_permits_ceiling, sql_reserve and active_tenants.
Under isolation = "strict" each running statement draws an engine pool of its own rather than one
per (dataset, tenant), and the analytics session cache is sized from what the split leaves over
(session_cache_capacity, 16 at the default ceiling). At the 2,048 MB default with the shipped
512 MB limit the strict ceiling is still two permits, so nothing changes until an operator gives a
cursor more. In shared isolation the arithmetic is as before.
GET /_admin/tenants adds per tenant active, waits_total and rejections_total, and under
gates the same per chain with a wait_seconds summary (count, sum, p50, p99 and the buckets),
rejections split into busy and tenant_share. The same waits are the histogram
nuthatch_sql_admission_wait_seconds{tenant}, for at most 256 tenant labels; the rest share
tenant="other".
A PUT /_admin/runtime that changed max_rss_mb did not re-check the memory split boot holds the
permits to, so under strict isolation it could accept a ceiling the permits did not fit (#2491). Both
figures are now checked on every change, as boot checks them, and a ceiling that cannot hold the
permits is 409, naming the chain and the arithmetic.
Nests that progress independently (FR18)
A chain's cursor ran each nest's window in turn, so one slow nest set the tip lag of every nest on its
chain, and a re-admitted nest pulled the cursor back so its siblings fetched again. The cursor is now
an extraction stage feeding a bounded window buffer, with one ingest task per nest reading it from its
own position (#2506). Extraction still fetches each range once with the union filter and decides
each reorg once; a reorg drops the buffered windows above the common ancestor and leaves a marker,
and each nest rolls back from its own position with the unchanged rollback_reorg. A nest that falls
behind the buffer, or comes back from a quarantine, fetches for itself by its own filter until it
reaches the buffer, and never moves extraction back. A block over the provider's cap is now asked for
by each nest's own filter, so only a nest still over the cap is quarantined.
One reorg issues one marker (#2515). Before it, nests slow to roll back still held positions above
the fork, extraction jumped forward to them and issued the same marker again on every pass, 128 times
on CI, past the 64 kept, so every nest fell back to checking its own checkpoints. A nest's position
now counts toward extraction's floor only once it has applied every marker issued;
one_reorg_issues_one_marker_while_its_nests_are_slow_to_apply_it saw 54 markers before and 1 after.
This is the default cursor for a runtime from 5.14. A lone nest outside a runtime runs its own loop,
which is unchanged. Every suite passes on both cursors, and the parity tests store the same rows row
for row, through reorgs too. With one nest slowed tenfold its siblings' p50 tip lag was 8 to 9.5 ms,
against 541 to 802 ms on the shared cursor; tip lag's after-seen p50 was 28 to 33 ms on either cursor
on a laptop. The figures and the method are in RFC-0076 §9. On the runner that enforces the dense
footprint gate, 20 nests on one cursor peaked at 414 to 427 MB over seven runs with the buffered
cursor as the default (median 423, 362 to 364 MB at the tip), against the 602 MB ceiling and the
earlier band of 387 to 481 MB (rss-band.yml runs 40933697538 and 33956127005); the ceiling is
unchanged.
What the buffer holds is charged to the cursor:
window_buffer_mb, 64 MiB at the default 2,048 MB ceiling, scaling withmax_rss_mbas the
entity cap does, is part of every cursor'sprojected_mband is reported byGET /_admin/runtime.
A live change to the ceiling reaches a running cursor at its next window.- Past it, windows spill to
<runtime>/cursors/<chain>/buffer/, up to four times the bound. The
directory is scratch, never data, and is emptied when the cursor starts. NUTHATCH_INGEST_CONCURRENCYis how many nests on a cursor process a window at once, by default
the core count and at most 4. A sibling waits for a slow nest only when every permit is held by
slower ones; keep it above the number of nests you expect to be slow.
process_window is now split into a part that decodes, reads, checks and binds, with no side effect a
retry would see, and a commit that is not abandoned once begun. That split is what RFC-0073 FR6 said
the window deadline needed, so [mounts.limits] window_deadline_ms, set on the mount that indexes the
dataset and live by PATCH /_admin/mounts/<name>, abandons the first part at the deadline with
nothing stored and the window asked for again. The third overrun in a row is a retryable quarantine
naming the deadline. It applies on both cursors.
New series: nuthatch_nest_window_seconds, nuthatch_nest_window_overruns_total,
nuthatch_nest_behind_extraction_blocks, nuthatch_nest_extraction_wait_seconds_total,
nuthatch_cursor_buffer_bytes and nuthatch_cursor_buffer_spilled_bytes.
Followers on another host (FR17)
5.13's follower read segments, nest config and offchain snapshots from the writer's directory, so it
had to run on the writer's host. nuthatch serve --follow <writer> --mirror <mirror> --registry <registry> --cache <dir> [--max-rss-mb N] runs one that shares no path with the writer (#2502). It
takes sealed segments from the writer's mirror, each checked against the hash its catalogue names;
each nest's config from the registry by the NID the feed's mount line carries, refused unless it
computes to that NID; and offchain snapshots from the mirror's _offchain/. The admin token comes
from NUTHATCH_ADMIN_TOKEN alone. --cache is the follower's own directory, laid out as a
runtime's. --runtime still selects the follower beside the writer, which is unchanged.
A sealing delta whose catalogue names a segment the follower does not hold is held, with the deltas
behind it for that dataset, until every file has arrived and verified, then applied whole. A slow
mirror shows as lag, never as a short answer: meanwhile the follower answers the generation before the
seal, and /<tenant>/<alias>/ready says under follower.mirror what it waits for and why the last
fetch failed. A mount whose NID the registry lacks answers 503 unservable. A cached file that does
not hash to its name is removed, fetched again and listed under cache_refused; a segment nothing has
named for 5 minutes leaves the cache.
A mirror publishes for followers only when asked. followers = true in [runtime.publish] or
[mounts.publish] makes the publisher also upload provisional tails to _provisional/, offchain
snapshots and their catalogue to _offchain/, and a _followers.json marker, and delete a
provisional tail a fold replaced once every connected follower has moved past it and the 5-minute
grace is up, or after an hour. Offchain snapshots may be data an operator never meant to publish,
and the credentials then need delete, so it is off by default. Off, a publish pass puts and deletes
exactly what 5.13.0 did. Sealed segments stay append-only either way.
Feed v2. A follower asks for ?feed=2 and a writer that speaks it answers
application/vnd.nuthatch.feed-v2: length-prefixed frames, each table's puts an Arrow IPC batch
LZ4-compressed behind its size, which the follower checks against its budget before allocating. On
windows of decoded transfers it is about a sixth of v1's bytes and costs about seven times v1 to
encode, once per delta however many followers it goes to. A writer that does not speak v2 answers
NDJSON, which the follower reads as v1, and a 5.13 follower still gets v1 from a 5.14 writer.
Visibility is measured on the writer's clock: a follower acknowledges each applied generation within
10 ms with its round trip, and the writer records nuthatch_feed_visibility_seconds{dataset,kind},
kind being tip or seal. Beside it on the writer are nuthatch_feed_delta_bytes{encoding},
nuthatch_feed_encode_seconds{encoding} and nuthatch_feed_connection_queue_bytes{conn}; a follower
serves nuthatch_follower_apply_seconds, nuthatch_follower_seal_wait_seconds and, on another
host, nuthatch_follower_mirror_{files,bytes,refused,missing}_total. Locally, over loopback with a
filesystem mirror, tip deltas were visible within 5 ms and remote seals within 100 to 250 ms, all of
it waiting for the publisher. Cross-region latency has not been measured; GraphOps's
second-region environment is what answers it, and CI cannot. tests/e2e_remote_follower.rs gates the
answers against a local follower, over S3 too, and scripts/rolling-upgrade.sh gains a remote leg.
A dataset whose offchain pull moves its data identity also moves its mirror prefix; a remote follower
follows the new prefix within 30 s, once the publisher has filled it.
One snapshot per request
A request could see a window's derived state out of step with its rows, velocity before its threshold
flags or rows before the entity built from them, and 5.13 fixed that on followers with a lock that a
long /sql held, so each commit queued behind it (#2467). Writer and followers now publish one
snapshot per window, a hot-store read transaction and one immutable version of each view, and each
request answers from the one it pinned at its start (#2494). With a 0.5 s /sql looping beside the
commits, tip lag's after-seen p50 stayed at 23 ms where the lock took it to 355 ms, and point-read max
fell from 441 ms to 6 ms. Versions still being read are charged to the per-cursor ceiling and gauged
as nuthatch_snapshot_retained_bytes{nest}. Scaled mode pins each request to an exported Postgres
snapshot.
The core crate (RFC-0075)
A nest's window path, reorg rollback, redb hot store and the bodies of the query routes moved into a
new workspace crate, nuthatch-core, which the binary calls and which also builds for wasm32 to run a
whole nest in a browser tab (#2486, #2496, #2505, #2512). For a binary user nothing changes: the
routes answer byte for byte as before, pinned by tests/e2e_tab_answers.rs against the unrefactored
node, and the segment-hash pins and reorg suites pass with their bodies untouched. The dbsp patch the
tab needs lives only in spike/dbsp-wasm and is not in the binary's dependency graph. The tab itself
is not part of this release.
CI and the release gate's own scripts were fixed for Ubuntu 26.04 runners, and pull requests now run a
fast tier with the slow tier left to the merge queue (#2495, #2497, #2503, #2507); none of it touches
the binary.
Behaviour changes
Replace the binary and restart. A 5.13 store is used as it is. Before upgrading a runtime:
- The buffered cursor is the default for every runtime cursor. Each nest on a chain is now its own
task reading a shared buffer, and each cursor's admission is chargedwindow_buffer_mb(64 MiB at
the default ceiling), so a runtime packed within 64 MiB of its ceiling starts its last mount
quarantined.NUTHATCH_CURSOR_BUFFER=0(oroff) restores the shared cursor, and that switch is
kept for 5.14 only. A number sets the most windows the buffer holds, 64 by default. A lone nest is
unaffected. - A cursor may write scratch under
<runtime>/cursors/<chain>/buffer/, up to four times
window_buffer_mb, emptied at the cursor's start. - Tenant reservations follow activity, not mounts. An idle tenant holds no permit, and a gate
keeps a reserve ofmax(1, sql_permits / 8)for tenants holding none. At the default two permits a
tenant beside others still uses one, as in 5.13; with more permits a lone active tenant may borrow
all but the reserve. Response-byte and hot-copy reservations are unchanged. sql_permitsis no longer capped at 16, and is set by[runtime] sql_permitsor live, ahead of
NUTHATCH_SQL_MAX_CONCURRENCY. APUT /_admin/runtimeloweringmax_rss_mbbelow what the
permits' memory split needs is now409, where 5.13 could accept it.- Feed v2 is negotiated. A 5.14 follower asks for
?feed=2and reads v1 from a 5.13 writer; a
5.13 follower gets v1 from a 5.14 writer. A rolling upgrade from 5.13 therefore works in the order
scripts/rolling-upgrade.shtakes, followers first, and this is the first release the
rolling-upgrade gate runs across two releases. - A mirror is unchanged unless
followers = true. Turning it on publishes offchain snapshots and
deletes folded provisional tails from the mirror. window_deadline_msis new and unset by default. A mount without it behaves as before.- Requests answer from a published snapshot, so a long query holds the view versions it pinned,
and their bytes count against the cursor's ceiling until it ends.