Quick revision
The short answer
Split brain is when two nodes of a replicated database both believe they are the primary and accept writes independently. It happens when a failover promotes a standby while the old primary is still running and still reachable by some clients, typically during a network partition. It is worse than downtime because the two copies silently diverge, two orders with the same id or a balance spent twice, and reconciling them is manual and may lose data; we prevent it with quorum-based decisions, fencing such as STONITH or revoking the old primary's access, and self-demotion when a node loses quorum.
What to remember
In this answer, we saw that split brain means two nodes both act as primary and accept writes, usually after a failover promotes a standby while a partitioned old primary is still serving some clients. The divergence produces duplicate ids, double-spent balances and conflicts that need manual reconciliation, which makes it far worse than visible, recoverable downtime. We prevent it with quorum-based decisions, fencing such as STONITH or revoking access, and self-demotion when a node loses quorum.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Split brain is when two nodes of a replicated database both believe they are the primary and accept writes independently. It happens when a failover promotes a standby while the old primary is still running and still reachable by some clients, typically during a network partition. It is worse than downtime because the two copies silently diverge, two orders with the same id or a balance spent twice, and reconciling them is manual and may lose data; we prevent it with quorum-based decisions, fencing such as STONITH or revoking the old primary's access, and self-demotion when a node loses quorum.
Why this question is asked
High availability exists to keep a database writable when a server fails. Split brain is the failure of high availability itself: in trying to stay available, the system ends up with two masters. It is rare, but when it happens it does far more damage than the outage it was meant to prevent. Interviewers ask about it to see whether we understand that a failover system must be designed around what it cannot know. In this answer, we will recap the single-primary rule, walk through how a partition produces split brain, see what the divergence looks like in business data, explain why it is worse than downtime, and go through the defences.
1A Quick Recap: One Primary at a Time
In a replicated database such as PostgreSQL with streaming replication, or MySQL with a source and replicas, exactly one node, the primary, accepts writes. The standbys copy its changes. This single-writer rule is what keeps every copy consistent: there is only one order in which changes happen, and everyone follows it.
Failover breaks that rule for a moment by design. When the primary seems to be gone, we promote a standby so writes can continue. The question that decides everything is how sure we are that the old primary is really gone, and not just unreachable from where we are looking.
2How a Network Partition Produces Two Primaries
A network partition is a split in the network where some machines can talk to each other but not to the others. Imagine a primary in zone A and a standby in zone B, with application servers in both zones. The link between the zones fails. From zone B, the primary has vanished: health checks fail, replication stops. A failover tool in zone B promotes the standby. But the old primary is fine. The application servers in zone A can still reach it, and they keep writing.
7 messages in order. Play them, or step through them one at a time.
Both nodes accept writes; neither knows the other exists.
3What the Divergence Looks Like
Now both nodes accept writes, and their data drifts apart with every transaction. Sequences on both hand out the same next values, so two different orders get id 1001. A customer with a balance of 150 spends 100 in each zone, and both nodes allow it, because each sees a balance of 150. A product with one item left is sold twice. Every change is valid on the node that made it, and that is exactly the problem: no error is raised anywhere.
When the partition heals, there are two histories that cannot be merged automatically. PostgreSQL physical replication cannot combine them at all; one node must be rewound and its writes after the split extracted and reconciled by hand. For each conflicting record, a person has to decide which version is right, and for some, like the balance spent twice, there is no right version, only a business decision about who absorbs the loss.
4Why It Is Worse Than Downtime
Downtime is visible and recoverable. When the database is down, monitoring screams, users see errors, and when it comes back, the data is correct. The cost is lost time and some lost revenue.
Split brain is silent. Everything looks healthy while it happens, both nodes answer queries, and the corruption may go unnoticed for minutes or hours, spreading into invoices, emails, shipments and downstream systems that consumed the wrong data. Undoing it is manual work across many systems, and some of it cannot be undone at all. So a well-designed failover system prefers to stay down rather than risk two primaries. Availability is only valuable if the data is right.
5Preventing It: Quorum, Fencing and Self-Demotion
The first defence is quorum: decisions about who is primary are made by a majority of an odd number of voters, typically three or five members of a consensus store such as etcd, Consul or ZooKeeper, as Patroni does. During a partition, at most one side can have a majority, so at most one side can promote a primary.
The second is fencing: making sure the old primary cannot accept writes before the new one starts. The bluntest form is STONITH, shoot the other node in the head, which powers it off through a management interface. Gentler forms revoke its access: remove it from the load balancer or proxy, move the virtual IP, change security group rules, or revoke its storage.
The third is self-demotion: a primary that loses contact with the quorum assumes it may have been replaced and stops accepting writes on its own, before the others can promote someone else. In Patroni, the leader demotes itself if it cannot renew its leader key in time, and a watchdog reboots the node if Patroni itself hangs.
- Primary unreachable from the failover sidecould be a crash or a partition
- Does this side have quorum?YesContinueNoDo nothing, stay read-only
- Fence the old primarypower off, revoke access or wait for its self-demotion
- Promote the most up-to-date standbyonly now
4 steps in order. Play them, or step through them one at a time.
6Follow-up questions
Can split brain happen with a managed cloud database?
Managed services are designed to prevent it with their own fencing and quorum, so it is very unlikely within the service. It can still happen in our own architecture, for example when an application caches a direct IP of the old primary or when two separate clusters are both configured as writable during a migration.
Why do two-node clusters struggle with this?
With two nodes, a partition leaves one vote on each side, so neither side can know whether the other is dead or just unreachable. Either both stay down, or both may promote. Adding a third voter, even a small witness node or an external consensus store, breaks the tie.
Does synchronous replication prevent split brain?
It helps in one specific way: an old primary that loses its synchronous standby cannot acknowledge new commits, so clients on its side see hanging writes instead of successes. But it is not a substitute for fencing, because settings can fall back to asynchronous, and reads still return stale data.
7Conclusion
In this answer, we saw that split brain means two nodes both act as primary and accept writes, usually after a failover promotes a standby while a partitioned old primary is still serving some clients. The divergence produces duplicate ids, double-spent balances and conflicts that need manual reconciliation, which makes it far worse than visible, recoverable downtime. We prevent it with quorum-based decisions, fencing such as STONITH or revoking access, and self-demotion when a node loses quorum.
Open with
Split brain is when two nodes in a replicated database both think they are the primary and both accept writes. The classic way it happens is a network partition.
Then, if they want more
Say the primary is in zone A and the standby in zone B, and the link between zones breaks. From zone B the primary looks dead, so a failover tool promotes the standby. But the old primary is alive, and application servers in zone A can still reach it, so now both sides take writes.
Their data diverges: both hand out order id 1001 for different orders, a customer spends the same balance twice, the last item is sold twice. Nothing raises an error, because each write is valid locally.
When the network heals, there are two histories that cannot be merged automatically; someone has to rewind one node and reconcile the conflicting records by hand, and some conflicts have no correct answer.
That is why it is worse than downtime: downtime is visible and the data is still right afterwards, while split brain silently corrupts business data that spreads to other systems. To prevent it, decisions need quorum, a majority of an odd number of voters like an etcd cluster, so only one side can promote.
The old primary must be fenced, powered off or cut off, before promotion. And a primary that loses quorum should demote itself, as Patroni does when it cannot renew its leader key.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is split brain in a replicated database, how can it happen during a network...": https://scrivio-interview-library.netlify.app/databases/replication-and-ha/b5ae302593/