Wiki Cluster
Joining, draining and decommissioning nodes
A node's life in a Mirexa cluster — admission to the control plane, voter promotion, draining its partitions off, decommissioning, and what happens when a node comes back.
A node enters a Mirexa cluster in two moves — it is admitted to the control-plane Raft group first, and registered as a data node last — and leaves it in three: an operator asks for a drain, the cluster moves every partition role off the node, and the cluster decommissions it, after which the process exits on its own. Every step is driven by the leader's loops; an operator issues exactly one call at each end.
Node statuses
| Status | Meaning |
|---|---|
ONLINE |
Serving; may hold partitions and receive new ones |
LEAVING |
Draining: still serves what it holds, receives nothing new |
OFFLINE |
Fenced: the cluster has stopped believing it (see Failover) |
OFFLINE_ |
Fenced and draining — the two are independent facts, so a fence never cancels a drain and a restart never undoes one |
DECOMMISSIONED |
Drained and removed from the consensus group; its registration is refused forever until an operator deregisters it |
A JOINING status does not exist: registration is the last step of startup, so a registered
node is already admitted, caught up and serving.
Joining
A node joins when it has cluster.seeds (control addresses of existing members) and an empty
cluster.initial_members. Startup runs in this order:[1]
- Admission. Before building anything else, the node asks a seed's control plane
(
JoinControlPlane) to admit it to the Raft group as a non-voter, then waits until its own log holds what the cluster had decided at that moment. This comes first because the partition count and the codec the storage layout and dispatcher are built with are the cluster's, and they arrive only by log replication. Failure is fatal aftercluster.join_timeout(1 m); an orchestrator restarting the process is the retry. A restarted node that is already in its own Raft configuration skips admission entirely, so a control-plane outage cannot block a restart. - Settings. The agreed cluster settings are read from the node's own applied state (see The control plane).
- Storage, WAL recovery, dispatcher, listeners — as on a single node.
- Registration. The node registers its Raft, data, control and replication addresses and
begins heartbeating. It is
ONLINEfrom the first accepted registration.
A configuration with neither seeds nor initial_members is refused at startup — such a node
could never be registered and would look healthy while nothing routed to it. TLS for the control
client is set up before consensus, because admission is the first outbound call.
An id already in the group at a different address is refused admission (ALREADY_EXISTS):
re-admitting it would silently rewrite a voter's address and cut it off from the log.
Measured 2026-10-07 (BenchmarkJoin_SeedToOnline, in-process, one development laptop): 111 ms
from a node starting consensus to registered ONLINE — admission, catch-up, settings,
registration and first heartbeat, excluding layout, WAL recovery and listener startup, which
depend on the data the node holds.
A node that joins a cluster whose partitions are all placed receives no partitions automatically unless
cluster.rebalance_autois on or the replication factor needs a home for missing copies. Otherwise read the rebalance plan and move partitions withMigratePartition(see Operating a cluster).
Voters
Every node is admitted as a non-voter: it receives and applies the log but counts toward no quorum, so an empty-logged joiner cannot raise the quorum before it can answer. The leader promotes, on a deterministic rule; no node promotes itself:[2]
- The group grows toward
cluster.voters(default 3; odd, 1–7). It never shrinks a larger group, because hashicorp/raft cannot demote a voter in place (the call succeeds and changes nothing). - A candidate is a non-voter that is
ONLINEand whose own Raft commit index, reported on a recent heartbeat, is within 256 entries of the leader's. The control API being reachable is not evidence the Raft log reaches a node — a wrongraft_addrheartbeats fine over gRPC. - The voter count never moves to an even number: one voter and one ready candidate stay as they are, and both promote once a second candidate is ready.
- Lowest node id first, so a new leader mid-way reaches the same group its predecessor was building.
- A draining or decommissioned voter counts as already gone, so its replacement is promoted first: the group goes 3 → 4 → 3, never 3 → 2.
The voter count bounds how many control-plane failures the cluster survives (three voters survive one, five survive two). It is not the cluster's size.
Draining
DrainNode(node_id) records an operator's intent that a node leave: ONLINE becomes LEAVING,
OFFLINE becomes OFFLINE_LEAVING. Draining a node that is already down is allowed — it is the
common case of decommissioning a dead machine. Draining a node already draining is refused.[3]
From then on:
- Nothing new lands on it. Adding a copy to a draining node is refused; placement and the rebalancer skip it; a migration whose target starts leaving before its flip is abandoned.
- The drain loop moves its roles off (every 1 s), as ordinary migration intents, so a drain
uses the same seed, cutover, pacing and abort machinery as any move:
- Primaries first. While the node is still primary of anything, only its primaries move —
each to the lightest
ONLINEnode by the rebalancer's own measure (movable primary bytes, in-flight moves counted where they are going), largest partitions first, never onto a node already holding a copy. A fenced (OFFLINE_LEAVING) node's primaries are not planned: they move by failover instead. - Then copies. Once it is primary of nothing, each copy it holds moves as a secondary move: add the new copy, let it catch up from the primary, then drop the old one. The partition never holds fewer copies than it started with. A dead node's copies move too, since a new copy seeds from the primary; a copy whose primary is fenced is not planned.
- At most twice
max_concurrent_migrationsdrain moves are recorded at once.
- Primaries first. While the node is still primary of anything, only its primaries move —
each to the lightest
- Progress is
ListDrains: per draining node, its status, primaries held, copies held, and migrations naming it.
Decommissioning
When a draining node holds nothing and no migration names it — checked, not claimed — the drain
loop decommissions it (DECOMMISSION_NODE). Then:[4]
- The promotion loop removes it from the Raft group (after promoting any ready replacement). A decommissioned leader first hands leadership to another voter, and its successor removes it, so the group never sits leaderless while every primary's lease lapses.
- The node's next heartbeat is refused; it re-registers; once it is no longer a group member, the
leader answers with a final
NodeDecommissionedrefusal — the one registration refusal a joiner does not retry. The node runs its ordinary shutdown and exits with status 0. - Restarted on its old data directory, it is refused the same way and exits 0 without serving.
Its own log still says it is a member, so the refusal comes from the registry record, which is
why the record is kept as
DECOMMISSIONEDrather than deleted. DeregisterNoderemoves the record. It is refused while the directory still names the node, and it is the deliberate act that makes the id reusable. Raft itself would admit a removed id again; the registry is what keeps a decommissioned process out.
A node that comes back
| How it left | What happens when it returns |
|---|---|
| Restarted or briefly unreachable, not fenced | Nothing changes; it keeps its partitions |
| Fenced, partitions not yet failed over | Re-registers ONLINE and keeps them |
| Fenced, partitions failed over | Its copies are divergent: it quarantines that data, asks back in, and re-seeds as a copy of the new primary (see Failover) |
| A partition it held was moved or dropped while it was away | Its files for that partition are moved aside as -; if it is given the partition again it seeds from nothing |
| Decommissioned | Refused; exits 0 |
Measured drain times
Measured 2026-10-09 on one development laptop (BenchmarkDrain_AtProductionCadences, two real
data planes, 4,096-partition keyspace, about 42 candles per partition — no data volume to speak of
and no real network): each move took about 6.6 s end to end, almost all of it waiting for loop
cadences (drain loop, migration loop, the target's 2 s supervisor pass twice, the 1 s tail
heartbeat twice), and moves run max_concurrent_migrations at a time:
| Partitions | max_ |
Drain time |
|---|---|---|
| 10 | 2 | 33.0 s |
| 10 | 4 | 21.0 s |
| 500 | 2 | 1,503 s (25 min), a steady 3.0 s per partition (run once, by hand) |
So drain time ≈ ⌈partitions ÷ limit⌉ × 6.6 s, plus each partition's seed transfer, which this
benchmark does not exercise. Raising max_concurrent_migrations shortens a drain at the cost of
more simultaneous seed traffic.
References
Source
admitToControlPlane,startJoin,clusterContacts, startup andshutdowncontrol.Joiner,JoinControlPlane, promotion loop, drain loopState.Register,BeginDrain,Decommission,Deregister,State.PlanDrain- Group membership
Tests
BenchmarkJoin_SeedToOnline— /cmd/server/join_test.goTestJoiner_ADecommissionedNodeIsRefusedAdmissionAtOnce,TestJoiner_AMemberWhoseSeedsHaveAllLeftStillReachesTheCluster— /internal/control/join_test.goTestRaftCluster_NonVotingReplicaIsNotCountedInQuorum,TestRaftCluster_DemotingAVoterInPlaceIsASilentNoOp,TestRaftCluster_ARemovedIDCanBeAdmittedAgain— /internal/raft/election_test.goTestPromotionSweep_NoEvidenceNoPromotion,TestPromotionSweep_TakesADecommissionedMemberOutOfTheGroup,TestPromotionSweep_ADecommissionedLeaderHandsLeadershipAwayFirst— /internal/control/promotion_test.goTestState_ADrainSurvivesTheNodeBeingFenced,TestState_ADecommissionedNodeStaysOut— /internal/cluster/state_test.goTestDrain_ALeavingNodesPrimariesMoveWithNobodyCallingAnythingElse,TestShutdown_TheClusterPlanesStopWhileTheDataPathStillServes— /cmd/server/drain_test.goTestClusterAPI_ADecommissionedNodeIsToldOnlyOnceItHasLeftTheGroup,TestClusterAPI_ADecommissionedNodeIsNeverAdmittedAgain— /internal/control/cluster_service_test.goTestServerBinary_ADecommissionedNodeExitsOnItsOwn— /tests/server_binary_decommission_test.goBenchmarkDrain_AtProductionCadences— /cmd/server/drain_bench_test.go
Further reading
- The control plane
- Moving partitions and rebalancing
- Failure detection, leases and failover
- Operating a cluster
External
- HashiCorp Consul, "Autopilot" — https://developer.hashicorp.com/consul/docs/agent/config/config-files#autopilot
- Diego Ongaro, "Consensus: Bridging Theory and Practice", PhD thesis, Stanford 2014, chapter 4 (cluster membership changes) — https://github.com/ongardie/dissertation
admitToControlPlaneanderrCannotJoinincmd/server/join.go;startConsensusincmd/server/main.go. ↩︎internal/control/promotion.goheader andpromotionMaxLag. ↩︎State.BeginDrainininternal/cluster/state.go;internal/cluster/drain.goandinternal/control/drain.go. ↩︎State.DecommissionandStatusDecommissionedininternal/cluster/state.go; promotion loop ininternal/control/promotion.go. ↩︎