Switchover and failover for MariaDB, step by step
A replica you never switch to is a backup with extra steps. Two operations make it a standby: a planned switch of roles, and a takeover when the master is gone. They are different, and the difference is where data gets lost.
The planned switch
For maintenance, a move, or simply to prove that the standby works. Both servers are alive, so nothing has to be guessed.
- The master blocks writes for a moment.
- The replica applies everything the master wrote, down to the last transaction, and confirms it.
- The replica becomes the master. The old master starts following it.
On our own pair, under continuous writes, this took 3.5 seconds from start to finish. The application saw a pause of under half a second, and every acknowledged write was on both servers afterwards, checked row by row.
The takeover after a failure
The master is gone and cannot be asked for anything. Replication is asynchronous, so the last transactions may not have reached the replica. No tool can change that after the fact. What a tool can do is be honest about it.
- The replica is promoted on your confirmation, not by itself. A network glitch should not start a second master.
- It says how many transactions may not have arrived, counted from the last positions both servers reported.
- From that moment it accepts writes, and you point your applications to it.
When the old master comes back
This is the corner where replication setups break. A server that was replaced boots up and still believes it is the master.
- A returning master blocks its own writes until it knows its place. There are never two masters accepting writes.
- If it holds nothing the new master lacks, it rejoins as a replica without copying anything.
- If it holds transactions that never arrived, they are counted and shown. A rejoin that would lose them silently is refused; you decide what to do with them, and the server is then given a fresh copy.
Checked on every release
Eight role-switch scenarios and seven interruption scenarios run against real MariaDB servers under load before a version ships: an agent killed in the middle of a switch, a job that writes on the replica, a master that returns after it was replaced. When ZeroBehind cannot be sure, it stops and says why.
After a switch you can compare every table on the replica with the master, piece by piece, at the same point of the replication stream, while replication keeps running.
What it does not do
- It does not fail over by itself. A person confirms a takeover.
- It does not move an IP address or change DNS. After a switch you point the applications to the new master.
- It is not synchronous replication. A crash of the master can cost the last moment of writes, and the console tells you how much.
Want to see it on your servers?
Tell us what you run. We answer with what is covered and what is not.
Talk to us