Study notes · 13% of the exam

Replication, Consistency and Transactions

Know exactly what each replication scheme and isolation level promises, which anomalies it still allows, and what the stronger guarantee costs in latency and availability.

Key points

  1. 1

    Asynchronous followers lag. Session guarantees (read-your-writes, monotonic reads, consistent prefix) patch the common anomalies cheaply, for example by pinning a user's reads to one replica.

  2. 2

    Leaderless quorums overlap when R + W > N, but sloppy quorums, concurrent writes and last-write-wins clocks all break the 'always fresh' intuition.

  3. 3

    Snapshot isolation prevents dirty reads, non-repeatable reads and lost updates, but allows write skew. Fix write skew with SERIALIZABLE (SSI), FOR UPDATE locks on the premise rows, or a constraint.

  4. 4

    Serializability is about transactions matching some serial order; linearizability is about recency in real time. Strict serializability is both.

  5. 5

    2PC blocks: a participant that voted YES can neither commit nor abort until it learns the decision, so make the coordinator's log highly available.

  6. 6

    PACELC: even without a partition, strong consistency costs latency. A cross-region majority write costs at least one round trip to the nearest follower.

Common traps

  • A YES vote in 2PC is not a commit; other participants may have voted NO.

  • READ COMMITTED doesn't fix write skew; it allows even more anomalies than snapshot isolation.

  • Raft and Paxos commit on a majority, not on every replica, so one failed replica out of three doesn't stop writes.

Test yourself on Replication, Consistency and Transactions

Ten questions, with the answer and explanation after each one.