Metadata keyspaces
The five keyspaces Nova keeps in its metadata store, their keys, and the rules every change follows.
The metadata store holds what object storage cannot: stream configuration, where each stream's records are, ledger state, leadership, and pending background work. Record bodies never go there. Three rules govern it. Every change is a compare-and-set (CAS) on one record. A change across several records is a series of steps, each safe to retry. Every lookup is a point read, a floor read, or a bounded prefix scan, so nothing scans a whole keyspace.
An append does not wait for the metadata store once its stream has a leader. The indexer writes where the records are afterwards, in batches. See The metadata store stays off the acknowledgement.
Where it lives
| Package | What it owns |
|---|---|
internal/kv | The store interface: Store, Locality, and Flat, with the mem and oxia backends and one conformance suite for both |
internal/metadata | Every durable record schema and its CAS rules, in the streams, queues, registry, and dispatch keyspaces; keys.go owns the key schema |
internal/coord | The sessions keyspace: liveness, node stats, writer leases, rings, and job claims |
internal/kv/oxia/embedded | Oxia running inside the nodes: founding the keyspaces, joining, splitting, and draining; see The embedded metadata store |
kv.Store is held only by metadata and coord. Every other component uses those wrappers.
The storage interface
Nova uses a small key-value interface. Oxia is the production backend, and an in-memory backend passes the same conformance tests. Reads and writes are linearizable. Each value has a version for conditional writes.
| Operation | What it does |
|---|---|
Get, Put(expected), Delete(expected) | Point access. Every write names an expected version: a concrete version, NotExists (a safe create), or AnyVersion (used only where a record has one writer by construction) |
PutEphemeral | A write bound to the client's session. The record disappears when the session ends, as the server judges it. Liveness, leases, and claims use it. |
FloorGet(prefix, probe) | The greatest key at or below the probe within a prefix. This is the reference lookup. |
Scan(prefix, after) | The direct children of a path prefix, in order, stopped early by the caller |
DeleteChildren, DeleteRange | The delete forms of a scan, within one shard of a locality |
PutIndexed, FloorIndex, ScanIndex, GetByIndex | Secondary indexes the backend keeps, written atomically with the record |
Within(localityKey) | A view that routes every operation by the locality key, so related records share one shard |
type Store interface {
Locality
// Within returns a locality whose records are colocated on the shard
// selected by localityKey. Every later operation on a record written
// through a locality must go through that same locality, or a sharded
// backend routes it to the wrong shard and it misses.
Within(localityKey string) Locality
}Values are Protocol Buffers. Unknown fields survive a read, change, and write, so an older node keeps a newer node's fields during a rolling upgrade.
Five keyspaces
The metadata store has five keyspaces, each an oxia namespace named <prefix>-<keyspace>. --oxia-namespace sets the prefix. Embedded oxia uses nova when it is unset. External oxia with no prefix keeps the streams, queues, sessions, and dispatch keyspaces together in oxia's default namespace, and the registry in nova-registry or on its own instance.
| Keyspace | Namespace | Holds | Kept as |
|---|---|---|---|
| streams | <prefix>-streams | Each stream's durable state: references, trim, last writer, fencing token, plus ledgers and decommission records | Durable and forward-only. Restoring an old copy would move epochs and trim points backward. |
| queues | <prefix>-queues | The auditor's due markers, orphan intents, and recovery claims | Busy and rebuilt from the other keyspaces; kept apart so its compaction stays off the streams keyspace |
| sessions | <prefix>-sessions | Liveness, node stats, writer leases, rings, and job claims | Bound to sessions and never backed up. Losing it costs coordination, not storage safety. |
| registry | <prefix>-registry | Stream addresses, buckets, and credentials | Durable, in natural key order, so prefix listings work at any depth |
| dispatch | <prefix>-dispatch | Everything a queue keeps beyond its messages | Busy like queues and kept apart for the same reason, but not rebuildable: it is backed up with the streams keyspace |
Two orderings are in use. The streams, queues, sessions, and dispatch keyspaces use hierarchical keys: / separates path segments, and a scan returns direct children. The registry uses natural order: / is part of the caller's stream key, a lookup routes by the full key, and a prefix listing uses byte order at any depth. kv.Flat is the registry's own type, so the two scan rules cannot be mixed.
Embedded oxia serves the registry itself as <prefix>-registry, on one node or many, and so does a clustered external oxia. An external standalone oxia knows one sort order. A deployment that uses one runs a second oxia instance for the registry and points --oxia-registry at it. The flag needs --oxia.
Key families
internal/metadata/keys.go owns every key in the four durable keyspaces. A key's bytes are a contract with every running cluster, and keys_test.go pins them.
Registry keyspace
| Key | Record | Index |
|---|---|---|
streams/<bucket>/<key> | The stream's descriptor at its address. The create with NotExists makes the address unique. A scalable stream's row also holds its range map. | stream-id, the reverse lookup by stream ID, swapped atomically on create, tombstone, and replace; queue, the bucket's queues |
internal/<bucket>/<id> | A stream without an address: a range, a parked stream, or a dead-letter stream, filed by ID and naming its parent | |
buckets/<name> | The bucket and its default stream configuration | |
credentials/<key-id> | An API-key credential, with its secret hashed |
A scalable stream's range map lives inside its registry row. The map is versioned, and each change (a split, a merge, a prune) names the version it expects and lands as one CAS on the row. The store has no multi-key write, so this is how a map change stays atomic with the stream's existence. The map only names the ranges. Each range is a stream of its own, with its row under internal/.
Per-stream rows
These live in the streams keyspace, all under the locality streams/<id>:
| Key | Record |
|---|---|
streams/<id>/refs/<firstSeq> | A reference row, keyed by its first sequence number (20 digits). A span ref names WAL slots and their footer ranges. A catalog row lists up to 128 stream objects. Each row holds its epoch and builder star. The by-ts index orders the rows by their earliest timestamp. |
streams/<id>/trim | The trim watermark, which only rises |
streams/<id>/writer | The last-writer record: the star and epoch that last opened the stream, written before its first acknowledgement |
streams/<id>/release | The clean-release record a departing leader writes, consumed by the next open |
streams/<id>/producer | The fencing token |
streams/<id>/lease (sessions keyspace) | The writer lease: the holder, bound to its session |
A range of a scalable stream is a stream with its own ID, so its rows sit under streams/<range-id> on a shard of their own. Only the range map on the parent's registry row is shared.
Ledgers
These live in the streams keyspace, under the locality ledgers/<star>:
| Key | Record |
|---|---|
ledgers/<star> | The mint counter: the last epoch, the head of each class, a writer record per class, and retired |
ledgers/<star>/<epoch> | One ledger (epoch padded to 20 digits): its state, its constants, its cursors, and its cut once fenced |
The streams keyspace also holds cluster/decommissioned/<star>, under the locality cluster/decommissioned/: the record that a star is gone for good, which every registration checks.
Epochs and fencing shows both records.
Due markers and intents
These live in the queues keyspace, under the locality due/<job>/<shard>:
| Key | Meaning |
|---|---|
due/<job>/<shard>/<order>~<rest> | One unit of work. <order> is a 20-digit ready time in milliseconds, or an inverted byte count for biggest-first queues. <rest> names the target: a stream ID, <star>~<epoch>, or an escaped object key. |
due/denorm/<shard>/<star>~<epoch>~<firstSlot> | A ledger's batch marker, ordered by first slot; the denorm-ripe index orders it by ready time |
due/orphan/<shard>/!<escaped-object-key> | An orphan intent: this object may exist before any reference names it |
recovery/<star>/<epoch> | The recovery claim, bound to the recoverer's session |
Each job queue has 64 shards, chosen by an FNV hash of the target. The auditor registers 14 duties, each with its own queue: teardown, teardown-final, recovery, retention, retention-check, reap, trimcheck, star-reclaim, denorm, gc, orphan, range-intent, range-split, and range-merge. Ready time and target share the last path segment, so a bounded scan of one shard returns its work in due order. The by-stream index lets the admin API list one stream's pending jobs without reading every queue. See Due-queues.
Dispatch keyspace
| Key | Record |
|---|---|
queue/<stream>/config | A queue's configuration |
queue/<stream>/keyed/<span>~<key> | Which copy of an idempotent send is the message |
queue/<stream>/replay | The lease of the one running dead-letter replay |
queue/<stream>/r/<range>/state, /purged | A range's delivery state and its purge point |
queue/<stream>/r/<range>/due/<ready>~<message>~<attempt> | A due key: a retry, a delay, or a pending dead letter |
queue/<stream>/r/<range>/claim/<seq> | A persisted claim |
dispatch/<shard>/<range>, dispatch-news/<group>/<range> | The dispatch index: 1,024 shards dealt to nodes, and 16 news groups |
The queue pages own these. See Persisted claims and Seat lifecycle and crash safety.
Sessions keyspace
| Key | Record |
|---|---|
cluster/stars/<star> | Liveness and routing facts: zone, location, addresses, leader count, load, saturated, draining |
cluster/stats/<star> | The node stats record: fixed-size load totals refreshed often, kept beside the liveness record so their churn never rewrites routing |
cluster/auditors/<star> | Auditor ring membership, which assigns due-queue shards by rendezvous hash |
cluster/dispatch/<star> | Dispatcher ring membership, which deals the dispatch shards |
auditor/lease/<job> | A job claim: at most one auditor runs a given job at a time |
Safe metadata updates
A create requires that the key does not exist. A read, change, and write names the version it read. A version mismatch means another writer changed the record, and the caller reads it again before it decides. A record with one writer by construction, such as the clean-release record under its lease, may use AnyVersion.
The store has no multi-key transactions. A change across records is a series of steps in a fixed order, each safe to retry. Denorm, for example, publishes an object, replaces the first reference row by CAS, deletes the covered rows in ascending order, and then resolves its markers. A concurrent lookup finds a valid reference at every step. Crash tests stop the sequence between every pair of steps and check that a retry converges.
Keeping related records together
All of a stream's rows in the streams keyspace share the locality streams/<id>: references, trim, writer, release, and producer. Per-stream work stays on one shard, and teardown is a fixed set of deletes on that shard. The writer lease uses the same locality key, but it lives in the sessions keyspace. Different streams hash across shards. A star's ledger records share ledgers/<star>, and each due-queue shard is due/<job>/<shard>.
Registry keys route on their own. Grouping a whole bucket's names on one shard would build a hot spot that no split could divide. Per-stream rows can stay together because they track batched objects, not single appends.
Finding records and pending work
A read uses FloorGet to find the reference row whose first sequence number is at or below the requested one, then searches within the row. A read by time, and retention by age, use one floor lookup on the by-ts index and then confirm the primary row. Listing a bucket's streams is a bounded, paged prefix scan.
Work is recorded when it is created: absorbing a batch, advancing a trim, publishing an object, or deleting a stream each arms a due marker. The auditor reads those markers in order. No request path lists every stream.
Sessions, pipelining, and batching
--oxia-session-timeout sets how fast a failure is detected: 10 seconds by default with external oxia, 15 with embedded oxia. A failed star's leases and liveness record stay until its session expires. Embedded oxia has the longer default because a frozen star there also stops answering heartbeats for the sessions on the shards it leads. The client sends a heartbeat at a tenth of the timeout, but at least two seconds apart. Any timeout up to 20 seconds therefore heartbeats every two seconds. See choosing the session timeout.
The client pipelines ordered writes, across failovers too. A write the server proves it did not apply, such as one refused while a shard leader starts or left unanswered at a graceful shutdown, is sent again in order. A write in flight when a connection breaks or a server crashes fails instead, because it may have applied. --oxia-write-window (4) limits batches in flight per shard, and --oxia-max-batch-kib (128) caps a batch. Together they bound metadata throughput and how much the absorb fan-out (--absorb-fanout, 4,096) can use.
Embedded oxia
By default, the nodes run the metadata store themselves. Every node runs an oxia data server, and the metadata peers also run the coordinator. Each keyspace is founded with a fixed number of shards, in a fixed order, and its replication factor rises to 3 once three data servers exist. The embedded metadata store covers founding, replication, draining a departing node's copies, and the crash points of each.
Splitting shards by measured load
Oxia never merges shards, so splits follow measured load. A streams shard is hot once it stays above 60% of 2,000 operations per second for 10 minutes. See Splitting shards by measured load.
Tests
internal/kv/kvtest: the conformance suite every backend passes, run againstmemand against oxia.internal/metadata:keys_test.gopins every key's bytes; the crash enumerations ofCommitCatalog, span commits, and ledger cursors.internal/kv/oxia/embedded: listed on The embedded metadata store.tlaplus/Registry.tlamodels the registry row and its CAS rules.
See also
Stream objects and denorm
How the auditor copies each stream's records out of shared transit bundles into stream objects of its own.
The embedded metadata store
How nodes run oxia themselves, from founding the five keyspaces to raising replication, draining a departing node's copies, and splitting hot shards.