Your three-node Galera cluster ran without incident for two years. Then the network team reboots a top-of-rack switch during what was supposed to be a quiet maintenance window. The cluster sees a partition, all three nodes lose quorum, every node refuses writes with WSREP has not yet prepared node for application use, and the application logs are filling with Unknown error 1047. The cluster will not self-heal — Galera is intentionally conservative here. Somebody has to pick the node with the most-advanced state and bootstrap from it. Pick wrong and you lose committed transactions. This is the runbook for picking right.
What’s happening
Galera (whether MariaDB Galera Cluster or Percona XtraDB Cluster) provides synchronous multi-master replication based on the wsrep protocol. Every committed transaction is replicated to a majority of nodes before the client gets a success. The trade-off: any time a node can’t see a majority of the cluster, it refuses writes and marks itself non-primary. This is what makes Galera safe — and what makes recovery from a full partition manual.
Three things can put a cluster into full split-brain (no node with primary state):
- Symmetric partition — the network splits the three nodes from each other but each node is alive. Each sees itself in a 1-of-3 minority and goes non-primary.
- Reboot storm — a power event or rolling restart that exceeds Galera’s wsrep state-transfer window. Nodes come back but can’t agree on which has the latest state.
- Asymmetric crash — node A crashes, B and C continue with primary, then B and C crash before A is restored. The cluster has no node that knows the latest committed seqno.
In all three cases the cluster has lost the ability to self-elect a new primary. You must identify the node with the highest committed seqno and tell it to bootstrap. Every other node will then re-sync via SST (full state snapshot transfer) or IST (incremental state transfer) from that bootstrapped node.
If you pick the wrong node — one with a lower seqno — the higher-seqno nodes will discard their newer transactions during SST. That’s data loss. The runbook below is structured to make picking wrong nearly impossible.
How to verify
Step one is identifying what state each node is in. Run on every node:
# Wsrep status — most useful single command
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_%';" | \
grep -E 'wsrep_(cluster_status|local_state_comment|cluster_size|last_committed|local_index)'
Expected outputs and what they mean:
wsrep_cluster_status | wsrep_local_state_comment | Meaning |
|---|---|---|
Primary | Synced | Healthy member of an active cluster |
Primary | Donor/Desynced | Currently serving SST to a joiner |
Primary | Joiner | Receiving SST from a donor |
non-Primary | Initialized | Lost quorum, refusing writes |
Disconnected | — | Not connected to other nodes at all |
If every node shows wsrep_cluster_status = non-Primary or Disconnected, you have a full split-brain. Do not restart mysqld. Do not run SET GLOBAL wsrep_provider_options="pc.bootstrap=yes" on a node you haven’t verified yet.
Step two is finding the most-advanced node. Galera writes the last-known position to grastate.dat:
# Run on every node
sudo cat /var/lib/mysql/grastate.dat
You should see something like:
# GALERA saved state
version: 2.1
uuid: a1b2c3d4-...
seqno: 38472619
safe_to_bootstrap: 0
The seqno is what you compare across nodes. The node with the highest seqno is the most up-to-date. The safe_to_bootstrap flag is Galera’s own opinion — if 1, that node was cleanly shut down last and is safe. If all nodes show 0 (common after a crash), you’ll set it manually.
If seqno is -1 on a node, mysqld didn’t write a clean shutdown marker. You need to recover the position from the InnoDB logs:
# Stop mysqld first if it's running
sudo systemctl stop mariadb
# Recover position
sudo mysqld --wsrep-recover
# Look in the error log for the recovered position
sudo grep "WSREP: Recovered position" /var/log/mysql/error.log | tail -1
# Output: WSREP: Recovered position: a1b2c3d4-...:38472619
That :38472619 is the recovered seqno for that node. Now you can compare across all three nodes.
The fix
You have collected three seqnos. Call them N1, N2, N3. The decision tree:
1. Identify the donor candidate. The node with the highest seqno is your bootstrap candidate. If two nodes tie, pick the one with the lower wsrep_local_index (it was a longer-running primary).
2. Confirm the donor is not a former minority. If your highest-seqno node is one that was on the minority side of a known partition (say, the cluster was 2+1 before the full partition and you have logs showing N3 was the lonely one), that node’s “extra” writes are uncommitted from the other side’s perspective and you should not bootstrap from it. In a true symmetric partition all three nodes will have the same seqno — that’s the common case. The asymmetric case usually shows N1=N2 > N3, and you bootstrap from N1 or N2.
3. Mark the donor as safe to bootstrap.
# On the chosen donor node
sudo systemctl stop mariadb # if it's running
sudo sed -i 's/safe_to_bootstrap: 0/safe_to_bootstrap: 1/' /var/lib/mysql/grastate.dat
sudo cat /var/lib/mysql/grastate.dat | grep safe_to_bootstrap
# safe_to_bootstrap: 1
4. Bootstrap the donor.
On Debian/Ubuntu with MariaDB:
sudo galera_new_cluster
On RHEL/Rocky/AlmaLinux with MariaDB:
sudo systemctl start mariadb@bootstrap
On Percona XtraDB Cluster:
sudo systemctl start mysql@bootstrap
Verify it came up as a primary cluster of size 1:
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_cluster_%';"
# wsrep_cluster_size 1
# wsrep_cluster_status Primary
# wsrep_local_state_comment Synced
5. Bring the other nodes in, one at a time.
Order matters: bring back the node with the next-highest seqno first. It might be eligible for IST (incremental) instead of full SST. Bringing back the lowest first means you SST everything, which on a multi-TB dataset is hours of wire time.
On the second node:
sudo systemctl start mariadb # not the bootstrap unit — the regular one
Watch the donor logs. You’ll see SST or IST starting:
sudo tail -F /var/log/mysql/error.log | grep -E 'WSREP|SST|IST'
Wait for the joining node to report Synced:
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_local_state_comment';"
# Synced
Only when the second node is Synced should you start the third. Bringing in two joiners at once against a single donor is supported but slow and stresses the donor’s I/O. Sequential is safer.
6. Confirm full cluster health.
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_cluster_%';"
# wsrep_cluster_size 3
# wsrep_cluster_status Primary
mysql -uroot -p -e "SHOW STATUS LIKE 'wsrep_local_state_comment';"
# Synced
All three nodes should show size 3 and Synced. Run a write on the bootstrapped node:
USE app;
CREATE TABLE _galera_recovery_check (id INT, ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
INSERT INTO _galera_recovery_check VALUES (1, NOW());
Confirm it landed on the other two within a second, then drop it.
7. Post-mortem follow-ups.
After the cluster is healthy, do three things:
- Set
pc.recovery=trueif it isn’t already inwsrep_provider_options. This lets the cluster recover from some classes of partition without a manual bootstrap — specifically when nodes come back with their last-known cluster view intact. - Configure
evs.suspect_timeoutandevs.inactive_timeoutto match your network. Defaults are conservative; if you have a flaky link, tightening these can prevent split-brain entirely by removing slow members faster. - Add a third site or arbiter if you’re running two-node + arbiter. Two-node Galera is one network blip away from this scenario. A
garbdarbitrator process on a third host (no data, just quorum vote) costs nothing and removes most of the failure modes.
Write the incident up. The exact seqnos, the chosen donor, the recovery time. Galera split-brain is rare enough that nobody remembers the runbook between events. The post-mortem is what makes the next one a 20-minute exercise instead of a 4-hour crisis.
For MySQL/MariaDB clusters where you’d rather not pick the donor at 3 a.m. yourself, we operate Galera and Percona XtraDB Cluster as part of Cloud Compute with the bootstrap decision tree built into our monitoring and on-call — or start a scoping call to hand the recovery path over.