Run the metadata store

Run the metadata store

Run Nova's metadata store inside the nodes or on machines of its own, and keep it healthy.

The metadata store records which buckets and streams exist, where each stream's records are in object storage, which node leads each stream, and the queues' state. It holds no record bodies. It is oxia, a replicated key-value store, and it can run inside novad or on machines of its own. Every node needs it to serve: when it is unreachable, appends and reads that need it wait or fail, while records already in object storage stay safe.

Choose where it runs

Inside the nodes (embedded)On its own machines (external)
What you runnovad onlynovad, plus oxia data servers and a coordinator
CopiesThree, on three nodes, once a cluster has threeAs oxia's configuration says, usually three
A node failsIts metadata shards fail over tooOnly its own streams fail over
Default --oxia-session-timeout15s10s
Scheduled backupsNoneYes, see Backups and restore
Use whenA few machines, and one binary to runMany nodes, metadata backups, or metadata work kept off the serving machines

Start embedded. A cluster can move the store to its own machines later while it serves, as described below. The rest of this page covers both shapes; Run Nova on machines shows how an embedded cluster starts.

How an embedded cluster is founded

Every node in a cluster runs a data server, which holds copies of shards. The three metadata peers named in --oxia-server-peers also run the coordinator, which places shards and elects their leaders. The first address in the list is the founding peer: when it has no state, it starts the coordinator's raft group alone, and the other nodes join it. The first node to register its data server creates the five keyspaces (streams, queues, sessions, registry and dispatch). The leading peer raises each to three copies once three data servers exist.

Which node creates the keyspaces matters only when the founding peer was a standalone node with data. The cluster keeps using that data only if the founding peer creates the keyspaces itself, before any other node registers. So restart a former standalone node first, wait until it serves, and only then start the others, as Grow a standalone node into a cluster shows.

Use an external metadata store

Write the cluster configuration

The coordinator reads which data servers exist and which namespaces they serve from one file. Nova needs five namespaces under one prefix, here nova. The registry namespace sorts keys in natural order, because it holds stream addresses that Nova lists by prefix.

/etc/oxia/cluster.yaml
namespaces:
  - name: nova-streams
    initialShardCount: 4
    replicationFactor: 3
    notificationsEnabled: false
  - name: nova-queues
    initialShardCount: 4
    replicationFactor: 3
    notificationsEnabled: false
  - name: nova-sessions
    initialShardCount: 8
    replicationFactor: 3
    notificationsEnabled: false
  - name: nova-registry
    initialShardCount: 1
    replicationFactor: 3
    notificationsEnabled: false
    keySorting: natural
  - name: nova-dispatch
    initialShardCount: 4
    replicationFactor: 3
    notificationsEnabled: false

servers:
  - name: oxia-1
    public: oxia-1:6648
    internal: oxia-1:6649
  - name: oxia-2
    public: oxia-2:6648
    internal: oxia-2:6649
  - name: oxia-3
    public: oxia-3:6648
    internal: oxia-3:6649

The shard counts are the ones an embedded store starts with. Oxia can split a shard later but never merges two. Nova subscribes to no notifications, so they stay off.

Start the data servers and the coordinator

On each of three machines, with oxia 0.17.1:

oxia-1, oxia-2 and oxia-3
oxia server --public-addr 0.0.0.0:6648 --internal-addr 0.0.0.0:6649 \
            --data-dir /var/lib/oxia/db --wal-dir /var/lib/oxia/wal

Then the coordinator, on a machine of its own:

oxia-coord
oxia coordinator --cconfig /etc/oxia/cluster.yaml \
                 --file-clusters-status-path /var/lib/oxia/cluster-status.json
Flag --cconfig has been deprecated, --cconfig is deprecated; configure cluster config through metadata.file.configName or metadata.kubernetes.configName
INF Starting Oxia coordinator …
INF Elected new leader component=shard-controller …
INF Shard is ready component=shard-controller …

The deprecation notice is harmless; the Kubernetes operator starts its coordinator the same way, and runs one. While the coordinator is down, shards keep serving through their current leaders, and a shard whose leader fails waits for it to return. Oxia can also run three coordinators on its raft provider; see oxia's own documentation for that shape.

Start the nodes on it

Point every node at any one data server with --oxia, and name the prefix with --oxia-namespace. The node learns the shards and their leaders from that server.

nova-1
novad --dir /var/lib/nova --listen :7780 --fleet-listen :7790 --metrics-listen :9090 \
      --advertise nova-1:7780 --zone az-1 \
      --oxia oxia-1:6648 --oxia-namespace nova \
      --s3-bucket nova --s3-endpoint http://rustfs:9000 --s3-region us-east-1 --s3-path-style
[INFO] novad: external oxia oxia=oxia-1:6648 oxia_registry=""

The node's directory now holds only its identity, and its startup table shows oxia-session-timeout 10s. A node whose prefix names a namespace oxia lacks refuses to start:

[ERROR] novad failed err="novad: oxia registry: kv/oxia: connect \"oxia-1:6648\": oxia: failed to retrieve the initial list of shard assignments: oxia: namespace not found"

The smallest external shape

For a test stack, two oxia standalone instances are enough: one serves the streams, queues, sessions and dispatch keyspaces in oxia's default namespace, and a second, started with --key-sorting natural, serves the registry. Leave out --oxia-namespace and name the second instance with --oxia-registry. The local stack runs this shape. A standalone instance keeps one copy, so do not use it in production.

Move the metadata store to its own machines

An embedded cluster can move its metadata store to external oxia while it serves. The move has two stages, each a rolling restart, and the cluster can rest between them. Stage one moves the data; stage two moves the coordinator. In stage two the external coordinators join the nodes' raft group, which takes a coordinator from the oxia build that Nova embeds: it has the --raft-peers flag that keeps the group equal to a list.

Stage one:

  1. Start the external data servers and attach each one to the cluster's coordinator. Attaching again is harmless.

    nova oxia attach --name ext-1 --public ext-1:6648 --internal ext-1:6649
    ext-1 attached to embedded oxia at ext-1:6648 (internal ext-1:6649); the balancer places shards on it as the factor allows
  2. Restart each node with --oxia <an external server> added and --oxia-server-peers kept. Such a node is detached: its clients use external oxia, and it asks oxia to release the data server it hosted. Its log says role=peer or role=member with detached=true. Wait for embedded: data server released and stopped before you restart the next node. Until enough external servers hold three copies, it logs embedded: oxia refuses to release this star's data server until more servers are attached once and asks again every 5 seconds.

Stage two:

  1. Restart the nodes with the peer list extended by the external coordinators' addresses. They use the same five-port layout as the nodes.
  2. Start the external coordinators on oxia's raft provider with that extended list. nova oxia peers shows them as voter once they have caught up.
  3. Restart the external coordinators with a list of only themselves.
  4. Restart the nodes with that list. A node that was leading hands over to a listed voter.
  5. Restart the nodes with --oxia and no --oxia-server-peers. Their coordinators stop.

Wait for the external leader to remove the nodes before step 7

Shortly after step 6, the leading external coordinator removes the nodes from the raft group. If the nodes stop their coordinators while they are still voters, the group keeps six voters with three gone, never elects a leader again, and stops until the nodes come back with their old lists. nova oxia peers cannot confirm the removal, because a removed node still shows itself as a voter. Wait until the leading external coordinator has logged Removing a server that is no longer a peer once for each node's raft address.

Replace a metadata peer

A member joins and leaves freely. A peer's address is in every node's list, so replacing a peer means editing the list:

  1. Replace the old address with the new node's. If the old address was first, move a surviving peer to the front: a first address that finds no state founds a new group, and a new node must never do that.
  2. Restart the surviving nodes one at a time, so that two peers stay up.
  3. Start the new node with the list and an empty directory. The leader removes the old address from the raft group and adds the new one, which shows joining until it has caught up, then voter.
  4. Decommission the old node once the new one has registered; see Decommission.

Split a hot shard

Each streams shard has one leader, which handles about 2,000 metadata operations per second. When a shard stays above 1,200 operations per second for 10 minutes, the leading peer logs embedded: shard hot past the window once at Warn, and the gauge nova_oxia_server_hot_shards counts it. On machines you split it yourself; on Kubernetes the operator does.

nova oxia hot
nova oxia split --namespace nova-streams --shard 0 --point 500000000
no shard above the split trigger
shard 0 of nova-streams: split accepted at 500000000

oxia hot prints the oxia split command for each hot shard. Without --point, oxia cuts where the shard's load suggests. A shard with no recorded load needs an explicit point on the 32-bit hash ring, or the split fails with embedded: nothing left to cut. A split is immediate and permanent. Cluster commands lists the options of every nova oxia command.

On Kubernetes

With spec.metadataStore.placement: Embedded, the operator runs this shape for you. It renders one StatefulSet per zone, makes the first pod of each zone a peer, and keeps the coordinator's state in ConfigMaps under a Lease instead of raft. It keeps the volumes when pods go, and it splits hot shards on its own. Changing the placement to External starts the move, which the operator walks through the stages AttachingServers, Detaching, Succeeding, Dropping and Migrating. See Install Nova on Kubernetes.

Choose the session timeout

A node holds a session in the metadata store, and its leases end when the session expires. --oxia-session-timeout therefore sets how long a failed node's streams wait before another node can take them. The client sends a heartbeat every 2 seconds for any timeout up to 20s. So the timeout sets how many heartbeats a session can miss, and how long a stall it survives: the timeout less 2 seconds. Garbage-collection pauses of tens of milliseconds do not matter. Stalls of seconds do: CPU throttling at a container's limit, memory pressure, or a paused VM.

  • External, 10s. A node that stalls for more than 8 seconds loses its own sessions and restarts. Nothing else does.
  • Embedded, 15s. Every node also leads some metadata shards. A node frozen for more than 13 seconds expires the sessions of healthy nodes on the shards it leads, and two nodes down lose the metadata store's quorum. The longer timeout narrows that window.

Below 10s, a session survives fewer than four missed heartbeats. Set the flag only with a reason: it replaces the default in both shapes.

If it goes wrong

SymptomLikely causeWhat to do
oxia: namespace not found at start--oxia-namespace names a prefix the cluster configuration lacksAdd the five namespaces, or fix the prefix
A detached node never logs data server released and stopped; at --log-level debug it logs embedded: leave pending with oxia is still draining the data server: … replicas leftOxia has not moved the node's shard copies to the external serversCheck that the external servers are attached and reachable. Do not restart the next node until the release.
embedded: oxia refuses to release this star's data server until more servers are attachedFewer than three external servers are attachedAttach more servers
this star serves no embedded oxia from nova oxiaThe node uses external oxiaRun the command against the oxia deployment
A node exits with novad: metadata session lost; restart requiredThe metadata store did not hear from the node for longer than the session timeoutRestore the store's reachability, then restart the node; its supervisor should do that.

See also

On this page