Diagnosing and Recovering from Split‑Brain in MariaDB Galera Cluster
Detect split‑brain in MariaDB Galera Cluster by checking wsrep_cluster_status, network connectivity, and gcache, then apply the appropriate fix or escalate.
16 Sept 2025, 19:57 UTC

Recognizable Condition
Applications report stale reads, write timeouts, or errors such as "Lost connection" while the cluster status shows a value other than Primary for wsrep_cluster_status (e.g., Non-Primary, Disconnected, or Lost) and wsrep_ready is OFF.
Cause and Symptom Reference
| Cause | Symptom | Diagnostic command |
|---|---|---|
| Network partition between nodes | wsrep_cluster_status = 'Non-Primary' or 'Disconnected'; wsrep_ready = OFF | SHOW STATUS LIKE 'wsrep%'; |
| Node failure (crash/hang) | Remaining nodes show decreased wsrep_cluster_size; gcache errors in error log | SELECT * FROM mysql.wsrep_statistics; SHOW ENGINE INNODB STATUS; |
| Misconfigured wsrep_provider_options (e.g., pc.ignore_sb) | Cluster may incorrectly declare Primary despite divergence | SELECT @@wsrep_provider_options; |
Ordered Diagnostic Checks
- Verify network connectivity:
ping node‑addressandtelnet node‑address 4567from each host. - Check cluster status:
SHOW STATUS LIKE 'wsrep_cluster_status'; SHOW STATUS LIKE 'wsrep_ready'; - Inspect the MariaDB error log for messages containing
split brain,gcache, orstate transfer. - Confirm gcache size adequacy:
SHOW GLOBAL STATUS LIKE 'wsrep_gcache_size';compare with recent write volume. - If state snapshot transfer (SST) is needed, verify donor availability:
SHOW STATUS LIKE 'wsrep_local_state_comment';
Fixes Tied to Findings
- Network partition restored: after fixing routing/firewall, let the cluster auto‑heal. Monitor
wsrep_cluster_statusuntil it returnsPrimaryandwsrep_ready = ON. - Isolated node: restart
mysqldon the node after network fix; it will request an SST or IST from a donor. - Crashed node with gcache overflow: ensure a clean shutdown, then start
mysqld. If the node’s gcache cannot hold recent writes, remove its data directory (e.g.,rm -rf /var/lib/mysql/*) and let it rejoin to trigger a full SST. - Misconfigured pc.ignore_sb: revert the option to its default (
pc.ignore_sb=false) inwsrep_provider_optionsand restart the node; then verify thatwsrep_cluster_statuscorrectly reflects divergence.
When to Escalate
- More than 50 % of nodes report
Non-PrimaryorDisconnected. - Repeated SST failure after three attempts (check error log for
SST failed). - Suspected data divergence: run a checksum tool (e.g.,
pt-table-checksum) and confirm mismatch viawsrep_certify_status.
Limitations and Practical Verification
This guide detects split‑brain symptoms but cannot prove that divergent writes have not occurred without an explicit checksum. After recovery, run SHOW STATUS LIKE 'wsrep_cluster_status'; on all nodes and ensure each returns Primary and wsrep_ready = ON. Optionally, verify absence of split brain or gcache overflow messages in the error log.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.