Troubleshooting

Replication and cluster problems

Symptoms of replicas, synchronous replication, managed nodes and watcher quorums, with the checks that find the cause and the safe response to each.

First read what the node says about itself:

GET /v1/server            role, replication status, sync.degradedCommits   (any login)
GET /v1/control/state     epoch, role, writable, lease, dirty, rank, inSync (control account, managed nodes)
GET http://127.0.0.1:STATUS_PORT/status                                    (the node's watcher)

Replicas#

SymptomCauseWhat to do
Writes to a replica fail: READ_ONLY (12) or 403 read_only_replicaThat is what a replica doesWrite to the primary. To make the replica the primary: POST /v1/promote (an unrestricted admin; only on a server started as a replica).
raftdb-server: the replica profile needs replica-ofMissing replica-ofAdd it.
replication.lastError set; tables connected: falseThe replica cannot reach the primary, or its account may not read every databaseCheck the network and port; check replica-user (an unrestricted readonly account is enough); check the primary is up.
A replica re-copies a whole tableThe primary checkpointed (at start by checkpoint-min-mb, or on demand), so the replica's copy no longer continues the logExpected: a few seconds plus the copy time. Avoid on-demand checkpoints on a busy primary.
A replica is behindAsynchronous: it applies chunks as it receives themCheck appliedBytes against the primary; check the network and the replica's disk.
A table renamed on the primary is fetched again on the replicaRenames are not carried as renamesExpected.
Accounts differ between nodesAccounts are not replicatedGive every node the same user lines.
Replica of an lsm primary behaves slowlyEvery row is written twice on a replicating lsm serverSee Resource use and tuning.

Synchronous replication#

SymptomCauseWhat to do
Every write takes about sync-timeout-ms longerNo replica confirms, so each write waits the whole timeoutCheck the replica's connection; GET /v1/server shows sync.degradedCommits climbing.
sync.degradedCommits growsWrites were acknowledged without enough replicasFix the replica; those writes are not protected against a primary failure. Lower sync-timeout-ms to stop waiting so long, or set it very high to prefer blocking.
Writes fail with an error on a managed nodeStrict mode: an unconfirmed write is an errorBring the follower back.

Managed nodes and watchers#

SymptomCauseWhat to do
No node is writable after a startThe watchers have not formed a quorum, or no node was assigned yet. A managed node starts read-only.Check all three watchers run (a majority is needed), that cluster_peers is the same everywhere and that cluster_secret matches; look at each watcher's stderr.
writable false everywhere after killing a nodeTwo of three nodes are down (a minority never accepts writes)Bring a node back.
Writes fail for 10 seconds after the primary diedThe failover: fail_after plus the revoke wait (contact window + lease + margin) plus promotionExpected; shorten lease_ms at the cost of more false failovers (Failover).
The primary's node stopped writing but is runningIts watcher lost contact with the quorum, so the lease was not renewed (the fence working)Check that watcher and its network to the others.
A watcher says "unknown setting" or the quorum never formsA misspelt key; cluster_peers entries not of the form ID=WATCHERHOST:PORT@NODEHOST:PORT; address not this member's noderaftdb-watch --config F --check-config; fix.
control cannot be combined with replica-ofA managed node with replica-ofRemove replica-of; the watcher tells the node whom to follow.
A node refuses a role commandThe epoch is not higher than the node has seen, or it is not the right groupNormally the watcher handles it; if you restored an old control.state, the node remembers a higher epoch.
The restarted old primary does not take writesIt is dirty (it held an unconfirmed tail): it follows the new primary until cleanWait; GET /v1/control/state shows dirty and inSync.
409 not_leader over HTTPTable-group mode: that node does not lead the tableUse the node named in the answer, or the binary protocol.
A group is stuck without a primary after a failureFewer than members - sync_replicas nodes answered, so the leader will not assign (to avoid choosing a node without an acknowledged write)Bring back a node; with sync_replicas = 1 and three nodes at least two must answer.
sync_replicas and sync-replicas differThe watchers and nodes disagreeMake them equal.
After restoring an old copy, a node never becomes primaryIts data epoch or position is older than the others'It will follow instead; restore a node by letting it re-copy from the primary.
A group's leaders are all on one node after a failoverRebalancing has not fired (60 s default)Wait, or hand over: Handover and rebalancing.

What not to do#

  • Do not start a second server on a data directory, or edit control.state.
  • Do not run a single watcher for a cluster: it cannot fail over.
  • Do not run watchers on the nodes they decide for if you can put them on separate machines: a machine failure then takes down a node and a vote together.
  • Do not stop two of three nodes (or watchers) at once unless you accept no writes.

When it looks wrong#

Collect, from each node and watcher: the status JSON, GET /v1/control/state, the start-up settings with --print-config (secrets are hidden) and stderr, and send them with a bug report. The watchers' notify_file is an audit trail of what they decided.

See also#