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#
| Symptom | Cause | What to do |
|---|---|---|
Writes to a replica fail: READ_ONLY (12) or 403 read_only_replica | That is what a replica does | Write 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-of | Missing replica-of | Add it. |
replication.lastError set; tables connected: false | The replica cannot reach the primary, or its account may not read every database | Check the network and port; check replica-user (an unrestricted readonly account is enough); check the primary is up. |
| A replica re-copies a whole table | The primary checkpointed (at start by checkpoint-min-mb, or on demand), so the replica's copy no longer continues the log | Expected: a few seconds plus the copy time. Avoid on-demand checkpoints on a busy primary. |
| A replica is behind | Asynchronous: it applies chunks as it receives them | Check appliedBytes against the primary; check the network and the replica's disk. |
| A table renamed on the primary is fetched again on the replica | Renames are not carried as renames | Expected. |
| Accounts differ between nodes | Accounts are not replicated | Give every node the same user lines. |
Replica of an lsm primary behaves slowly | Every row is written twice on a replicating lsm server | See Resource use and tuning. |
Synchronous replication#
| Symptom | Cause | What to do |
|---|---|---|
Every write takes about sync-timeout-ms longer | No replica confirms, so each write waits the whole timeout | Check the replica's connection; GET /v1/server shows sync.degradedCommits climbing. |
sync.degradedCommits grows | Writes were acknowledged without enough replicas | Fix 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 node | Strict mode: an unconfirmed write is an error | Bring the follower back. |
Managed nodes and watchers#
| Symptom | Cause | What to do |
|---|---|---|
| No node is writable after a start | The 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 node | Two of three nodes are down (a minority never accepts writes) | Bring a node back. |
| Writes fail for 10 seconds after the primary died | The failover: fail_after plus the revoke wait (contact window + lease + margin) plus promotion | Expected; shorten lease_ms at the cost of more false failovers (Failover). |
| The primary's node stopped writing but is running | Its 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 forms | A misspelt key; cluster_peers entries not of the form ID=WATCHERHOST:PORT@NODEHOST:PORT; address not this member's node | raftdb-watch --config F --check-config; fix. |
control cannot be combined with replica-of | A managed node with replica-of | Remove replica-of; the watcher tells the node whom to follow. |
| A node refuses a role command | The epoch is not higher than the node has seen, or it is not the right group | Normally the watcher handles it; if you restored an old control.state, the node remembers a higher epoch. |
| The restarted old primary does not take writes | It is dirty (it held an unconfirmed tail): it follows the new primary until clean | Wait; GET /v1/control/state shows dirty and inSync. |
409 not_leader over HTTP | Table-group mode: that node does not lead the table | Use the node named in the answer, or the binary protocol. |
| A group is stuck without a primary after a failure | Fewer 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 differ | The watchers and nodes disagree | Make them equal. |
| After restoring an old copy, a node never becomes primary | Its 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 failover | Rebalancing 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.