Add and remove nodes

Add and remove nodes

Add a node to a running cluster, drain one, and retire it for good without copying any data.

Adding or removing a node moves no record data. Object storage holds every record, so a node only takes over or hands off the streams it leads: it becomes their leader, the one node that accepts their writes. A new node takes new streams at once. A drain hands a node's streams to the other nodes, and a decommission then retires the node's ID for good.

While a stream moves, its producer reconnects to the new leader once and resends what was not yet acknowledged. In a test drain under a steady producer, the producer saw no error.

Before you start

  • Run nova with admin access to any node, through --addr. On a cluster with authentication, use an admin credential; see Server authentication. Cluster commands lists every option of nova health, nova fleet, nova node drain and nova node decommission.
  • With the metadata store inside novad, every node also holds copies of metadata shards, and the cluster needs three nodes at all times. To remove one of exactly three, add its replacement first.
  • A node whose address is in --oxia-server-peers is a metadata peer. Retiring one also changes the peer list; follow Replace a metadata peer as well.
  • On Kubernetes, the controller runs these steps itself when the pool shrinks or rolls; see Upgrade a cluster.

Check the cluster

nova fleet lists the nodes that serve, and nova health describes the node you ask:

nova --addr novad-1:7780 fleet
nova --addr novad-1:7780 health
01a2047d-7011-79e4-8233-2ce5214d7029  zone=az-1 addr=novad-1:7780
01a2047e-3833-79ea-8482-16e98b2332d7  zone=az-2 addr=novad-2:7780
01a2047e-39ab-7322-9873-8152fa641c7c  zone=az-3 addr=novad-3:7780
SERVING  node=01a2047d-7011-79e4-8233-2ce5214d7029 zone=az-1 version=… leading=1

health prints SERVING or DRAINING, the node's ID, its zone, its version, and leading, the number of streams it leads. A node that has finished draining adds a second line, drained: safe to decommission.

Add a node

Start the new node with the same peer list as the others. Its own address is not in the list, so it joins as a member: it holds metadata shard copies and serves streams like a peer, and no other node needs a change.

novad-4
novad --dir /data --listen :7780 --fleet-listen :7790 --advertise novad-4:7780 --metrics-listen :9090 --zone az-4 \
      --oxia-server-peers novad-1:6660,novad-2:6660,novad-3:6660 \
      --s3-bucket nova --s3-endpoint http://rustfs:9000 --s3-region us-east-1 --s3-path-style
[INFO] embedded: initialising metadata role=member metadata=raft dir=/data/metadata namespace=nova peers="[novad-1:6660 novad-2:6660 novad-3:6660]" streams_shards=4 queues_shards=4 sessions_shards=8 registry_shards=1 dispatch_shards=4 shard_plan="founding floors; existing shards are preserved"
[INFO] embedded: data server registered node=01a20481-0823-7a34-a3d6-3dde12d89671 via=novad-1:6660
[INFO] embedded: metadata initialisation complete role=member detached=false addr=novad-4:6663 dur=462.477704ms
[INFO] novad: serving node=01a20481-0823-7a34-a3d6-3dde12d89671 addr=novad-4:7780 listen=[::]:7780 metrics_listen=[::]:9090 zone=az-4 location=local audit=on storage=s3 version=…

The node appears in nova fleet and can lead new streams at once. The metadata store moves shard copies onto it over time. Streams that already have a leader stay where they are while their nodes have room. A node above half its capacity hands one stream to a less busy node about every 30 seconds, and a saturated node hands one off every 5 seconds. Each move makes that stream's producer reconnect once. See Leadership and failover.

Drain a node

A drain empties a node of streams. The node stops taking new streams at once, and /readyz answers 503 draining. Producers already connected keep writing for a grace period, 30 seconds by default, so short sessions can finish. Then the node hands each stream it leads to another node.

Start the drain

nova --addr novad-2:7780 node drain
draining
DRAINING  node=01a2047e-3833-79ea-8482-16e98b2332d7 zone=az-2 version=… leading=1

Wait until it leads nothing

Ask for its health until leading=0 and the second line appear:

nova --addr novad-2:7780 health
DRAINING  node=01a2047e-3833-79ea-8482-16e98b2332d7 zone=az-2 version=… leading=0
drained: safe to decommission

With a producer writing to it, this node was drained 42 seconds after the order: the 30-second grace, then the handoff.

To cancel a drain, run nova --addr novad-2:7780 node drain --stop. It prints drain stopped, and the node takes streams again. A drain is not saved: a node that restarts serves again, so drain it again if you still mean to remove it.

A stream stays on a draining node when no other node can take it. The node logs serving drain: stream not handed off — the surviving fleet cannot re-home it, and the decommission below waits. Add capacity first. The node's background auditor also stops taking jobs when the drain starts, and leaves its work to the auditors on the other nodes.

--drain-session-graceNOVAD_DRAIN_SESSION_GRACEDefault30s
How long connected sessions and running background jobs get to finish once a drain starts

Remove a node for good

A decommission declares a node's ID gone for good. The cluster never accepts that ID again, and a new machine gets a new ID. Decommission a node only after it is drained, and stop its process only after the command says it is done.

Drain the node

Drain it as above, and wait for drained: safe to decommission.

Decommission it through another node

nova --addr novad-1:7780 node decommission --star 01a20481-0823-7a34-a3d6-3dde12d89671 --wait
oxia is still draining the star's metadata replicas; keep the star running — asking again every 5s
star 01a20481-0823-7a34-a3d6-3dde12d89671 decommissioned: it can never register again; replacement hardware mints a fresh id

The first line appears only while shard copies are still moving. The last step moves the node's metadata shard copies to the other nodes. Without --wait, the command returns before that ends, with exit code 3 and this message, and you ask again later:

novactl: client: the star's metadata replicas are still draining: decommission: novad: 01a20481-0823-7a34-a3d6-3dde12d89671: coord: the star's metadata replicas are still draining (embedded: oxia is still draining the data server: 01a20481-0823-7a34-a3d6-3dde12d89671 is DATA_SERVER_STATE_DRAINING, 0 replicas left); keep the star running, and ask again (-wait asks until done)

Stop the process

The decommission does not stop the process. Until you stop it, the node keeps running and still appears in nova fleet. Stop it with docker stop, systemctl stop or by deleting its pod. A drained node leads nothing, so it closes in about two seconds. If you start it again, it refuses to run:

[ERROR] novad failed err="novad: star 01a20481-0823-7a34-a3d6-3dde12d89671: coord: star decommissioned"

The decommission runs these steps, and each can be asked again after a failure:

  1. It checks that the node is drained and leads nothing. A node that no longer appears in nova fleet passes this check.
  2. It indexes the records the node acknowledged but had not yet recorded in the metadata store, the node's ledger recovery. It waits up to 30 seconds; a longer recovery goes on in the background, and the next request joins it.
  3. It hands the node's leftover storage to the auditor, which deletes it later.
  4. It writes the permanent record that stops the ID from registering again.
  5. It removes the node's data server from the metadata store, which then moves the node's shard copies to the others.
--starRequired
The ID of the node to retire, as nova fleet prints it
--wait
Asks again every 5 seconds until the shard copies have moved, for up to 15 minutes
--force
Skips the drained check, for a node that still appears in nova fleet but does not answer
--cool-down
Lets the auditor clean up on its normal schedule instead of at once

With exactly three nodes

The metadata store keeps three copies of every shard and never drops below that. On a cluster of three, the decommission of a drained node is refused at its last step:

novactl: rpc error: code = Internal desc = novad: remove 01a204a4-0ded-7215-8c94-647b5f36ee98 from embedded oxia: embedded: removal would leave fewer servers than the replication factor: failed to delete data server "01a204a4-0ded-7215-8c94-647b5f36ee98": failed precondition: cannot delete data server "01a204a4-0ded-7215-8c94-647b5f36ee98" because namespace "nova-streams" replicationFactor=3 exceeds remaining data servers=2

By then step 4 has already retired the ID, so the node can never serve again. Keep its process running, start the replacement node, then run the decommission again: it resumes at the step that was refused. On a cluster that had already retired a node, a test run took the request instead and stayed still draining until the replacement registered. Either way, add the new node first.

A node that crashed

A node that crashes leaves nova fleet once its metadata store session expires: 15 seconds with the metadata store inside novad, 10 with an external one. It stays registered in the metadata store, and its shard copies fail over to the other copies. Start it again with the same directory and it rejoins as itself.

If it is gone for good, decommission it. An absent node passes the drained check, and the auditor recovers its ledgers. Be sure first: a node can be absent for a while because of a network partition, and a decommission cannot be undone.

Stop a node

A stop signal (SIGTERM or SIGINT) starts the exit drain. The node stops taking new streams and background jobs, waits 5 seconds, and hands off the streams it leads within 30 seconds. Then it closes, with 25 seconds allowed for the close. A second signal skips the rest of the drain and goes straight to the close, and a third kills the process.

The log of a node that led one stream
[INFO] novad draining to exit; a second signal skips to close
[INFO] novad: exit drain started source=exit budget=30s adopted=false
[INFO] serving drain: stream handed off stream=01a2047d-99ee-720f-917a-694a1d5a03bd
[INFO] serving drain complete: this writer leads nothing
[INFO] novad: closing guard=25s
[INFO] novad: closed dur=305.465616ms

Every line also carries the node's node_id, left out here. That node stopped in 6 seconds, and one that led nothing stopped in under a second. Give the supervisor a kill deadline above the drain budget plus the close guard: 75 seconds for systemd's TimeoutStopSec, Docker's --stop-timeout and Kubernetes' terminationGracePeriodSeconds. A shorter deadline kills the node during the handoff, and another node must recover its streams instead.

--exit-drain-budgetNOVAD_EXIT_DRAIN_BUDGETDefault30s
The longest the exit drain runs before the node closes
--shutdown-on-stdin-closeNOVAD_SHUTDOWN_ON_STDIN_CLOSE
Treats the end of standard input as a stop signal, so a supervisor that dies takes the node with it

Two kinds of drain

Operator drainExit drain
Started bynova node drainA stop signal
Grace before the handoff--drain-session-grace, 30 seconds5 seconds
Ends whenThe node leads nothingThe node leads nothing, a pass hands off nothing, or 30 seconds pass
Can be reversedYes, with node drain --stopNo

A stop signal during an operator drain takes it over without a second grace. Once the exit drain starts, node drain --stop is refused with novad: shutting down — the exit drain is irreversible.

Health and readiness

Both endpoints are on the metrics listener, --metrics-listen.

EndpointAnswers
/healthz200 ok while the process runs. It checks no dependency, so an outage elsewhere does not restart every node.
/readyz503 draining during any drain, 503 registration: <reason> when the node cannot confirm its own registration, else 200 ok. The registration check takes at most 1 second and is reused for 5 seconds.

If it goes wrong

SymptomLikely causeWhat to do
decommission: star … is alive and not fully drained (drained=false leading=N)The node still leads streams, or was never drainedDrain it and wait for drained: safe to decommission
decommission: star … is registered but unreachableThe node is listed but does not answerDrain it if you can; if it is gone for good, add --force
Exit code 3, the star's metadata replicas are still drainingShard copies are still movingKeep the node running and ask again, or add --wait
removal would leave fewer servers than the replication factorThe cluster has exactly three nodesStart the replacement, then ask again
leading stays above 0 and the log says the surviving fleet cannot re-home itNo other node can take the streamAdd a node, then let the drain finish
A decommissioned node still appears in nova fleetIts process still runsStop the process
coord: star decommissioned when a node startsIts directory holds a retired IDStart it with an empty directory, which creates a new ID

See also

On this page