BlogMariaDB

MariaDB Galera Non-Primary: seqno and safe_to_bootstrap

Scott Sternloff

By Scott Sternloff, Senior Enterprise Architect

LinkedIn · Updated · 4 min read

MariaDB Galera Non-Primary: seqno and safe_to_bootstrap
On this page

Short answer

After a Galera split or full outage, bootstrap from the most advanced node only. Check wsrep_cluster_status on every node first: if one node is Primary, rejoin the others to it. If none is, find the highest seqno with grastate.dat or mysqld --wsrep-recover, then promote that node with pc.bootstrap=YES or start it with galera_new_cluster. Bootstrapping from any other node can lose data.

After a Galera split or a full outage, bootstrap from the most advanced node and no other. On each node run SHOW GLOBAL STATUS LIKE 'wsrep_cluster_status'. If any node reports Primary, rejoin the others to it. If none does, find the highest seqno, then promote that node with pc.bootstrap=YES or start it with galera_new_cluster. Steps are from the MariaDB Galera documentation, read 3 December 2026. For quorum design and node counts, see our Galera production guide, which this post does not repeat.

If a cluster is already down, our mariadb consulting engineers work through the same order of checks.

Is the cluster split, or is it completely down?

The two cases need different actions. A split-brain leaves both halves non-Primary, and a simultaneous crash or shutdown that loses quorum also needs a manual bootstrap. A single node failure loses no data: the node reconnects and runs a state transfer.

Status variableHealthyTrouble
wsrep_cluster_statusPrimarynon-Primary (isolated) or Disconnected
wsrep_readyONOFF means the node rejects almost all queries
wsrep_cluster_sizeMatches expected node countSmaller means a partition
wsrep_local_state_commentSyncedDonor, Joining, Joined or Initialized during transfers

The documentation says to step in only if no node returns Primary.

How do you find the most advanced node?

  1. Stop and check. Do not restart anything yet. Collect wsrep_cluster_status from every node.
  2. Read grastate.dat in each datadir. After an orderly shutdown it holds a seqno. After a full crash it shows seqno: -1.
  3. Recover the position. Run --wsrep-recover (written mysqld --wsrep-recover in the docs) on each node. It reads the InnoDB logs and reports the last known transaction position.
  4. Compare. The most advanced node has the highest seqno.
  5. Look at safe_to_bootstrap. It is 1 on the last node to shut down in an orderly stop. After a full crash all nodes show 0, which is why you compare positions yourself.

Galera refuses to bootstrap a node marked as unsafe and logs a message, so a refusal is a signal to re-check, not to force it.

How do you bring the cluster back?

If at least one node is alive but non-Primary, the least disruptive route is to run this on the most advanced node:

SET GLOBAL wsrep_provider_options='pc.bootstrap=YES';

The documentation describes this as non-destructive, and it can keep the GCache, which helps other nodes rejoin by incremental state transfer instead of a full snapshot. If the wsrep_provider plugin is enabled, use SET GLOBAL wsrep_provider_pc_bootstrap=ON; instead.

If every node is stopped, set safe_to_bootstrap: 1 in grastate.dat on the most advanced node, start it with galera_new_cluster (a systemd wrapper that runs the server with --wsrep-new-cluster) and start the others normally. Never use --wsrep-new-cluster when joining an existing cluster.

What happens when the other nodes rejoin?

A rejoining node gets an incremental state transfer (IST) if a donor's write-set cache still holds what it missed, and otherwise a full state snapshot transfer (SST). Watch wsrep_local_state_comment move from Joining to Synced on each node, and confirm wsrep_cluster_size matches before letting the application back in. pc.recovery is on by default and can restore the last saved component automatically after a full outage.

For a written runbook around this, see our Galera quorum loss support use case.

Why does a Galera cluster split into non-Primary halves?

A Galera cluster stays Primary only while a node can see more than half of the last known members, which is the primary component. With three nodes, one failure leaves two nodes that still hold quorum. With two nodes, or with an even number split evenly across two data centers, a network partition leaves each side holding exactly half, so neither side has quorum and both turn non-Primary. That is the split-brain case this post is about, and it is why an odd number of nodes is the usual advice. A Galera Arbitrator (garbd) can act as a voting member that stores no data, which gives a two-node cluster a third vote. Sizing the voting members is covered in the production guide linked above.

What should you check before the application reconnects?

Treat the first minutes after a bootstrap as a verification window, not a finish line.

  • Run SHOW GLOBAL STATUS LIKE 'wsrep%' on every node and confirm wsrep_cluster_status is Primary, wsrep_ready is ON and wsrep_cluster_size is the node count you expect.
  • Check how your proxy, such as MaxScale or ProxySQL, decides a node is healthy, and let traffic back only to nodes that report Synced.
  • Read the MariaDB error log on each node for state transfer messages and for any node that refused to join.
  • Before you edit grastate.dat or force a bootstrap, copy the datadir or at least that file, so a wrong choice of node can be examined afterwards rather than guessed at.
  • Once the cluster is stable, take a fresh backup and write down which node was bootstrapped and why. The next outage review will want that record.

Sources

Frequently Asked Questions

What does non-Primary mean in MariaDB Galera?

The node is not part of a component that has quorum, so it rejects almost all queries. wsrep_cluster_status reports non-Primary for an isolated node and Disconnected when the node cannot reach a cluster. The data on the node is not lost.

What is safe_to_bootstrap in grastate.dat?

It marks whether a node may start a new cluster. It is set to 1 on the last node to shut down cleanly. After a full crash every node shows 0, so you compare positions with mysqld --wsrep-recover and set it by hand on the most advanced node.

Can I bootstrap from any node?

No. MariaDB's documentation warns that starting the cluster from any node other than the most advanced one can result in data loss. Compare seqno values across nodes first.

Scott Sternloff

Author

Scott SternloffSenior Enterprise Architect

Senior Enterprise Architect at AceMQ. Writes the technical coverage here: RabbitMQ, Kafka and Redis architecture, clustering and migrations.

Talk to an engineer

Need a hand with MariaDB?

Senior engineers who run it in production. Get a quote or a free consultation, no sales pitch.

Free Consultation

Get Expert Eyes on Your MariaDB Environment

Whether you're troubleshooting a production incident, planning a migration, or want a second opinion on your architecture — our team is ready. No pitch, just answers.

Email Us