🎓 A1Learner
🔍
0 of 29 lessons completed

Split-Brain and Partitions

A network partition is a failure that splits a group of machines into parts that cannot reach each other, while each part keeps running. Split-brain is the fault in which two parts each believe they lead, and accept work that conflicts.

Define the problem

A group fails when the network, not a machine, is what breaks.

Machines in a partition are healthy. Their messages simply cannot cross to the other part.

Each part sees silence from the rest. Each part must guess whether the others died or merely became unreachable.

Acting on the wrong guess creates split-brain. Refusing to act at all keeps the data safe and stops the service.

Majorities decide who may continue

A group of 5 splits into parts of 3 and 2. Only the part of 3 holds a majority, so only that part may decide.

A group of 4 can split into parts of 2 and 2. A majority of 4 is 3, so neither part may decide.

Odd group sizes avoid the deadlocked split. That is one reason consensus groups favour odd sizes.

The minority part should say so plainly. Its requests fail fast, or wait, instead of pretending to serve.

How split-brain damages data

Suppose both parts of a group accept writes during a partition. Each part builds its own version of the truth.

One part sells the last seat. The other part sells the same seat to someone else.

When the network heals, the two versions meet. Some conflicts have no fair merge, and one accepted write must be undone.

Prevention beats repair. A part without a majority must refuse writes before the damage happens.

Staying safe during a partition

Designs place copies across separate data centers. A failure inside one data center then cannot strand a majority by itself.

A third small site can break ties. It holds no data and only votes on which part may continue.

Reads can continue where writes cannot. A minority part may serve older data if it labels the data as possibly stale.

Every part needs a way back. When the link heals, the minority part copies the majority's log before serving again.

Trade-offs and wrap-up

Refusing minority writes protects the data. It also turns a network failure into an outage for some users.

Allowing both parts to write keeps the service up. It also risks conflicts that no merge can settle fairly.

CAP named this choice first. Majorities are the machinery that makes the choice real.

Split-brain is prevented by majorities, not by hoping the network stays whole.

Partition outcomes for one group

GroupSplitCan a part decide?
Group of 53 and 2Only the part with 3
Group of 42 and 2Neither part

Exercise

A group of 5 splits into parts of 3 and 2. Which part may keep accepting writes?