When the network splits, does my database refuse writes or lose them?
One network split, two choices, animated.
Press Play, or step with the arrows. Switch engines to see the other choice.
The CAP theorem says that during a network partition, a distributed database must choose between answering every request and keeping every answer consistent. In practice that choice is not made by the product, it is made by a setting you pick, often per query.
No real database is "a CP database" or "an AP database". Each one gives you a setting, often per query, that decides what happens on the minority side of a split.
| Engine | Consistent choice | Available choice |
|---|---|---|
| PostgreSQL | synchronous_commit on with synchronous_standby_names, for example ANY 1 (s1, s2) | Asynchronous replicas, the default |
| MySQL | Group Replication, or semi-sync with AFTER_SYNC | Asynchronous replication, the default |
| MongoDB | w: "majority" and readConcern "majority" (w: "majority" is the default since 5.0, except in replica sets with arbiters, where the default can fall back to w: 1) | w: 1 |
| Cassandra | QUORUM for reads and writes (R + W > RF) | ONE |
| Redis | WAIT narrows the window, but failover can still lose writes | Plain replication |
Even with no split, the same setting trades latency for safety: every majority write waits for a second server, across racks or regions if that is where the members are placed. That is the other half of the trade-off, often called PACELC: if Partitioned, Availability or Consistency; Else, Latency or Consistency.
Measured: Notebook 9 lost 2,217 acknowledged Redis writes on a failover to a lagging replica, and Cassandra at ALL failed as soon as one node of three stopped. See Notebook 9 and What a commit waits for.
The same mechanism, replication and failover, what a commit promises, elsewhere on the site: in real incidents, in measurements, and in designs.
Pick an answer. You will see whether it is right, and why.
1. During the split, what did client 1 get from node 1 with w: "majority"?
Node 1 applied it alone but could not reach a majority, so it never confirmed it.
2. With Cassandra at ONE on both sides, two clients write different values to one row. What happens after the split heals?
Last write wins. That is the cost of staying available on both sides.
3. Replication factor 3 in Cassandra. Which choice keeps reads and writes consistent?
Two plus two is more than three, so every read overlaps the latest write.
How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.