How a write becomes durable

How a write becomes durable

How Nova stores an appended batch in object storage and decides when to acknowledge it.

When Nova acknowledges an append, the records are stored in object storage. They stay readable from any node, even if the node that took them stops a moment later. The acknowledgement waits for object storage only. The metadata store learns where the records are afterwards, in the background.

The write pathproducerappend sessionbatchessequencercontiguous 0,1,2…match_seq_numpoolnode-widebounded (blocks)flusherforms a flightassigns a slotledger: epoch 7, consecutive slotsslot 41committedslot 42committedslot 43committedslot 44in flightflight = transit bundlebucket set (K = 3, one per zone)express bucket · az-acopy confirmed ✓express bucket · az-bcopy confirmed ✓express bucket · az-cpendingPUTack at W = 2; no metadata write requiredafter the ack: absorb writes refs to theseslots in the metadata store; no bytes move
A flight becomes durable when its slot holds W copies across the bucket set. Standard: K=1, W=1 on one standard bucket. Express: K express buckets, one per availability zone, W=2.

The parts

PartWhat it does
LeaderThe node that currently serves a stream's writes. It numbers each batch.
PoolA node's buffer of accepted batches, one per class, shared by every stream the node leads
FlightThe batches the node writes to object storage together, as one object in each bucket
WALThe node's write-ahead log in object storage, one per class. Each flight takes the next numbered position in it, a slot.
LedgerA run of consecutive slots written by one writer. A WAL is a sequence of ledgers, each with its own number, the epoch.
Bucket set and copy quorumThe K buckets each slot is written to, and the W of them that must confirm
IndexerRuns on the leader after the acknowledgement and records in the metadata store where each stream's records are

From append to acknowledgement

  1. A producer sends a batch to the stream's leader. A batch holds at most 1,000 records and 1 MiB, and Nova stores all of it or none of it. The leader gives each record the next sequence number. If the batch carries a match sequence number that is not the next one, the leader refuses that batch at once and reports the tail.
  2. The batch joins the node's pool for its class. The pool holds at most 256 MiB by default. When it is full, producers wait.
  3. One loop, the flusher, turns the pool into a flight once 8 MiB has gathered, or once the oldest byte has waited 200 ms on Standard or 25 ms on Express. The same loop gives the flight the next slot, so slot order is the order in which batches arrived.
  4. The node writes the flight to its slot in every bucket of the class's bucket set. Each write succeeds only if no object exists at that key yet. The slot is committed when W buckets confirm.
  5. The node acknowledges in slot order. A flight's batches are acknowledged once its slot is committed and every earlier slot has been acknowledged. Each acknowledgement gives the batch's sequence numbers, and it is never taken back.
  6. The indexer then writes each stream's share of the flight to the metadata store and moves the ledger's checkpoint past it. This step is called absorb. Until it finishes, only the leader knows where those records are. It serves them from memory or from the slot.

The metadata store stays off the acknowledgement

The write to the slot is the commit. An append touches the metadata store only when a node takes the lead of a stream or starts a new ledger, never once per batch.

A simpler design writes a metadata row for each batch before acknowledging it. That costs several metadata operations for every MiB, each copied three times inside the metadata store, and puts a metadata commit inside every acknowledgement. Deriving the rows afterwards, from a log that is already in order, takes that commit out of the latency and cuts the metadata work by about two hundred times. Absorb writes one row per stream for each group of flights, however many bytes they hold. Every acknowledged record can also be found again from object storage alone.

What an acknowledgement waits for

Once a stream has a leader, an acknowledgement waits for object storage and nothing else. The metadata store catches up in the background, and its work depends on how many streams are active, whatever the volume of bytes.

The cost is a short window in which only the leader knows where the newest records are. After a failure, the next leader rebuilds that from the WAL, as described below.

One log per node, shared by every stream

A node writes the streams it leads into one WAL per class, so a flight mixes records from many streams. Object storage charges per request and adds a fixed delay to each one. Sharing flights keeps the number of requests per second flat however many streams a node leads, and keeps each object large.

Standard storage limits the request rate under one key prefix until it splits a busy one, so each new Standard ledger starts at a hashed place in the key space.

In exchange, a stream's recent records are spread over shared objects, called transit bundles, and are read by byte range. Later, the auditor (Nova's background process) runs a job called denorm. It copies each stream's records into stream objects of their own, which suit long reads and retention. Both classes keep stream objects in the standard bucket, and Express records leave transit sooner because express storage costs more. See the transit window.

Acknowledgements follow slot order

Up to 128 slots per class upload at once by default. This hides the latency of each storage write. Acknowledgements are still released in slot order, so every stream sees its batches acknowledged in the order it sent them. A ledger's committed slots also have no gaps, which gives recovery a simple rule: every slot before the first one that cannot commit is committed.

The cost is head-of-line blocking. A slow write delays the acknowledgement of every later slot in that WAL, for every stream on the node, even when the later uploads have finished. When all 128 slots are waiting, the flusher waits, then the pool fills, then producers wait.

Two classes, one protocol

Standard and Express use the same slots and the same ordering. They differ in the bucket set and how long a flight waits.

StandardExpress
Flight cut8 MiB, or the oldest byte at 200 ms8 MiB, or the oldest byte at 25 ms
Buckets per slot (K)1 standard bucket1 express bucket per availability zone, at least 2
Copies to acknowledge (W)12 by default, never fewer
Durable at acknowledgementIn the region's standard storageIn two availability zones

With three zones, Express acknowledges after the second-fastest copy, so one slow or unavailable zone does not delay it. The quorum stays at two even when a zone is down. Each flight costs K writes to express storage. See Storage classes inside for the costs.

What waits when storage slows

Every step has a limit, and at each limit the step before it waits.

LimitDefaultWhat waits
A producer session's unacknowledged batches48 MiB Standard, 8 MiB Express, and 1,024 batchesThe client stops sending
The pool256 MiB per classNew batches
Slots uploading at once128 per classThe flusher
The backlog: flights acknowledged but not yet absorbed1,024 flights and 4 GiBNew slots

The backlog limit bounds the leader's memory, the window in which only the leader can read the newest records, and the work a successor must redo after a failure. Nova records each stall with its cause, such as absorb falling behind or a slow metadata store, and logs any wait longer than 5 seconds. See Backpressure.

When a node fails mid-write

A storage write fails

When a slot cannot reach its quorum, because too many buckets refuse it or its writes keep failing for 30 seconds, the node stops that ledger. It fences the ledger, starts a new one with the next epoch, acknowledges the flights committed before the stop, and writes the rest again into the new ledger. Producers see a delay. A call fails only if its own deadline passes first, and then nothing was appended.

The leader stops

Its lease ends when its metadata store session expires, after 10 seconds with an external metadata store or 15 seconds with the built-in one. The next leader runs ledger recovery before it serves:

  1. It fences the old ledger. It copies any partly written slot to enough buckets, then writes a marker into the first empty slot, so nothing at or after that slot can ever be acknowledged. That slot is the ledger's cut.
  2. It records in the metadata store where the records in every slot below the cut are. This moves no record data.
  3. It deletes slots above the cut that were written but never acknowledged.

A slot that was committed before the crash is kept, even if its acknowledgement never reached the client. A node that only seemed dead, because it paused or lost its network, finds the marker on its next write and stops.

What the client sees

The SDK finds the new leader and resends unacknowledged batches, within a 30-second retry budget. A batch that was already stored is appended twice. With a match sequence number, the resend is refused instead, and the client learns that an earlier attempt may have been stored. A one-shot append reports an uncertain outcome instead of retrying. Sequence numbers never have gaps. See Writer coordination for how to append exactly once.

Go deeper

Back to the concept: Appends.

On this page