advanced32 min studyLesson 27 in Engineering

Replication and consistency

Distinguish replica availability, linearizability, transaction isolation, and durable consensus when coordinating infrastructure.

On this page

What you’ll understand

  • Explain why quorum overlap is necessary for some protocols but not a complete proof.
  • Separate linearizable operations from serializable transactions.
  • Trace leader changes and safe-read requirements in a consensus system.

A model registry must not hand two controllers conflicting answers about the active production version. A metrics dashboard may tolerate a slightly stale count. These are different consistency requirements. Replication provides copies, but useful guarantees come from the protocol for writing, reading, and recovering those copies. Begin by stating what an observer may see and what should happen during a partition, then choose the mechanism.

Name the guarantee before selecting replicas

Linearizability makes each operation appear to take effect at one instant between its invocation and response, respecting real-time order. If a write has completed before a read begins, the read cannot return an older value in a linearizable register. Concurrent operations can be ordered either way if that order fits the history. Eventual consistency instead permits temporary disagreement under specified convergence conditions; it is often appropriate for derived views, but those conditions and conflict rules still need definition.

Serializable transaction isolation concerns whether committed transactions are equivalent to some serial ordering; by itself it does not add real-time ordering across transactions. Strict serializability combines those ideas. A database's read isolation and its replication durability settings are also separate dimensions. PostgreSQL's serializable transactions can abort to prevent anomalies, so clients must retry an entire failed transaction correctly. Do not infer a global consistency guarantee merely from the word replica or from one strong local transaction setting.

Understand what quorum arithmetic does and does not establish

With NN replicas, a majority contains ⌊N/2⌋+1\lfloor N/2\rfloor+1 members. Any two majorities overlap. More generally, fixed read and write sets overlap when R+W>NR+W>N. Overlap can ensure that a read encounters a replica that participated in a write, but the reader still needs correct version selection, write-completion rules, concurrency handling, and recovery. Sloppy quorums or partial writes change the argument. Arithmetic alone does not prove linearizability, transaction isolation, or durability.

Failures are not always independent. Three replicas on one host or in one power domain can disappear together. A majority-based consensus group of 2f+12f+1 voting members can continue making decisions with ff unavailable members under its protocol and network assumptions. It cannot guarantee progress in every asynchronous execution. During a network partition, a protocol preserving one decision history may have to stop accepting writes in a minority rather than let both sides invent incompatible histories.

q=⌊N2⌋+1,R+W>Nq=\left\lfloor\frac{N}{2}\right\rfloor+1,\qquad R+W>N
N, q, R, and W count replicas. The first expression is a majority size; the second guarantees overlap of fixed read and write subsets. Neither expression by itself specifies a correct read/write protocol.↔ Scroll wide equations horizontally.

Make reads and failover obey the same history

Raft orders commands through a leader and replicated log, using terms and voting rules to preserve committed history across leader changes. A former leader can remain alive after losing authority. For safe unlogged reads, a new leader first establishes committed current-term state, commonly with a no-op entry; a read then requires confirmation of current leadership and application through its established read position. Otherwise an apparently live leader may return stale data. Lease-based alternatives add explicit timing assumptions.

Infrastructure often coordinates external resources such as serving endpoints or storage writers. A stale controller may continue acting even after another wins election. Fencing tokens make the protected resource reject operations from older leadership generations, provided the resource actually checks them. A distributed lock without fencing is not an automatic defense against a paused owner resuming late. Test partitions, delayed messages, leader crashes, and stale clients against documented invariants; successful happy-path replication is weak evidence about failover safety.

accept⁡(e)  ⟺  e≥emax⁡,emax⁡←max⁡(emax⁡,e)\operatorname{accept}(e)\iff e\ge e_{\max},\qquad e_{\max}\leftarrow\max(e_{\max},e)
This illustrative resource-side rule accepts a nondecreasing fencing epoch e and remembers the greatest seen epoch. Same-epoch retries still need idempotency or sequencing; atomic enforcement at the protected resource is essential.↔ Scroll wide equations horizontally.

Analyze a five-voter registry

A registry has five voting replicas split by a partition into groups of three and two. Assume an otherwise correct majority consensus protocol. A controller with epoch 41 resumes after a new controller with epoch 42 has written to the protected resource.

  1. Compute the majority: floor(5/2) + 1 = 3. Only the group of three can form a voting majority.

  2. The two-replica side must not independently commit conflicting changes. Its replicas being alive does not grant authority to continue writes.

  3. For a linearizable read, still verify the protocol's leadership and applied-state conditions; a majority count alone is insufficient evidence of freshness.

  4. The protected resource has recorded epoch 42. Reject the resumed controller's epoch-41 operation, even if its process believes it still holds a lock.

The result

Majority availability explains which partition may progress; the consensus/read protocol and resource-side fencing provide the distinct safety properties.

Explore the model

Interactive lab

Interactive lab · reliability

Count a majority and challenge its meaning

Change replica count n and unavailable count k. Compare n − k with floor(n/2) + 1, then ask what the picture cannot tell you: log contents, read freshness, storage durability, network partitions, and Byzantine behavior are not modeled.

Count a majority and challenge its meaningA replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Current readings: Available replicas: 4 of 5; Majority needed: 3; Majority available?: Yes. All parameters are adjustable with the labeled controls below.Majority available · need 3 of 5Playback highlights fixed statesR1 · upR2 · upR3 · upR4 · upR5 · downCyan mark: majority threshold
AvailableUnavailableMajority threshold
Available replicas
4 of 5
Majority needed
3
Majority available?
Yes
t = 0 s

A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forMajority availability is a prerequisite for many consensus operations, not proof that arbitrary reads are linearizable.

Check your understanding

A design uses R + W > N. What can you conclude from that inequality alone?

Try it yourself

For seven voters, find the majority and the maximum unavailable voters that still leave a majority. Explain why four alive replicas with an unreachable network between them need not make progress together.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Count first, then consider communication. A voting set must exchange the protocol's messages, not just exist on a monitoring dashboard.

Compare with the solution

The majority is four, so at most three voters can be unavailable while leaving a majority. Four individually alive processes may still be unable to communicate and form a quorum. Even a communicating majority requires the protocol's leader-election and log rules; physical liveness is weaker than the ability to complete a consensus operation.

Take it with you

  • State the consistency guarantee at the operation and transaction boundaries.
  • Quorum intersection is set arithmetic, not a complete correctness proof.
  • Safe leadership changes require read rules, durable history, and often resource-side fencing.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.