Partial failure and consistency
One service, many independent failures
A distributed system coordinates processes across machines by exchanging messages. Unlike a single function call, a remote call can be delayed, lost, duplicated, or completed without its reply reaching the caller. A partial failure leaves some components working while others cannot communicate. A partition is a communication failure between groups of otherwise functioning nodes. A slow link can look identical to a failed link within a finite timeout. A timeout is a local observation, not proof the remote operation failed. Chapter 25 introduced message delivery; now consider a fictional bookstore where two replicas hold the available inventory. No real infrastructure is needed.
Follow the replica timeline
Initially replicas A and B store stock 10 at revision 1. At time 10 ms a client changes stock to 9 at A, which acknowledges at 20 ms. Propagation to B occurs at 80 ms. A second client reads B at 40 ms and obtains 10. At 90 ms B returns 9, assuming no additional writes. A successful response from B is not necessarily a fresh response. Synchronous replication waits for a configured acknowledgement condition; asynchronous replication can acknowledge before all copies receive the change. Replication improves some failure tolerance but does not replace backups, and synchronous acknowledgement is not proof every replica has applied the change. A write acknowledged on only one volatile replica can be lost when that replica fails. Always specify which replicas persist data and which replicas serve reads.
| Time (ms) | A | B | Observation |
|---|---|---|---|
| 0 | 10 | 10 | Both at revision 1 |
| 20 | 9 | 10 | Write acknowledged by A |
| 40 | 9 | 10 | Read B returns old value |
| 80 | 9 | 9 | B applies revision 2 |
| 90 | 9 | 9 | Read B returns new value |
Separate consistency guarantees
Linearizability makes each operation appear atomic at a point between its invocation and completion, respecting real-time order: if a write completes before a later read begins, that read cannot return an earlier value in the absence of another write. The timeline above violates that guarantee for the shared inventory register. Sequential consistency instead respects each client's program order without requiring global real-time order. Causal consistency preserves cause-and-effect relationships, such as a reply appearing after the message it answers. Eventual consistency means replicas converge when updates stop and communication and reconciliation proceed; it gives no universal deadline or guarantee that every read is fresh. Read-your-writes is a session guarantee; a client reading a different replica may need a session token or leader read. Monotonic reads avoid going backward within a session. These are different properties, not synonyms.
Transaction isolation concerns interference between concurrent transactions. Serializability means results are equivalent to some serial transaction order, not necessarily real-time order. Strict serializability also respects real-time ordering. ACID consistency concerns preservation of declared invariants, not CAP consistency. Durability concerns survival of committed changes under the specified failure model. For example, two checkouts each read stock 1, each subtract 1, then both write 0; two orders are accepted for one item. Prevent the lost update with an atomic conditional decrement or a transaction providing the required isolation, and check its result. A durable stale read can still be stale. Review exact read mode, isolation and failure guarantees rather than treating a database brand as one model.
Understand CAP under its assumptions
Consider two non-failed replicas separated by a partition in an asynchronous network. A write completes on A. A later read reaches B, which cannot learn the write. Returning the previous value violates linearizability; waiting indefinitely violates the theorem's availability requirement that requests to non-failed nodes eventually complete with a valid operation response. Rejecting that operation also does not preserve availability of the read/write object. CAP formalizes why both guarantees cannot hold in every such execution. Partition tolerance refers to the model admitting lost communication, not a feature you switch off by choosing a database. It is not a permanent choose-two label for an entire product. One operation might refuse writes to protect inventory while another serves stale catalog descriptions. When communication is healthy, coordination still has latency and throughput costs. CAP availability is not a measured monthly uptime percentage. See CAP reference and consistency models.
Reason about quorum and latency
A quorum is a subset large enough to satisfy a protocol's participation rule. In a fixed set of N replicas, read size R and write size W have guaranteed intersection if R + W > N; the minimum overlap is max(0, R + W - N). For N=3, R=2, W=2, at least one replica intersects. If one replica is unreachable, two remain, so both operations can still meet their counts. If two are unreachable, neither can meet a quorum of two. This arithmetic assumes a fixed membership, distinct replicas, and no substitutes. Intersection alone does not ensure linearizability: ordering, version selection, concurrent writes, durable acknowledgement, membership changes and read repair matter. Consensus protocols coordinate agreement on a history, often with majority quorums and leader terms; they require more than counting replies. A leader without a valid quorum must not accept conflicting commits.
Suppose a coordinator sends a write to three replicas concurrently; acknowledgement delays are 12, 35 and 80 ms. Waiting for two successful replies takes 35 ms in this simplified model, plus any omitted processing overhead. Waiting for all takes 80 ms. An unavailable replica contributes no finite acknowledgement. Cross-region links add propagation and tail latency; do not infer provider performance from this fixture.
Clocks, concurrency and ownership
Wall clocks on different machines can disagree or move backward after synchronization. Use a monotonic local clock for elapsed timeout measurement; it is not a globally comparable timestamp. Logical clocks can capture event ordering: on receipt, a Lamport counter advances to max(local, received) + 1. A smaller logical timestamp alone does not prove causation. For ordered state updates, a server-assigned per-entity revision can prevent older messages overwriting newer snapshots; distinct concurrent operations still require an explicit conflict policy. Avoid relying on last wall-clock timestamp for critical money or stock updates.
A distributed lock or lease grants temporary coordination rights, but a paused process may resume after expiry. Suppose worker A receives fencing token 7, pauses, and worker B receives token 8. If B writes first, the protected resource must atomically reject A's later token 7. A lease without enforcement by the resource is insufficient. Use established coordination services and transactional primitives instead of implementing a production lock in this lesson. Fencing requires monotonically ordered tokens and a resource that tracks and enforces them. It does not undo a previously accepted operation.
Compare a documented cloud example
Google Cloud Spanner external consistency describes real-time transactional ordering using its coordination and time mechanisms; its isolation documentation distinguishes serializable and repeatable read modes. Do not extrapolate these guarantees to every Google service, stale-read option or external side effect. Compare alternatives using the exact operation, read mode, geography, replication and transaction settings. For practice, explain the two reads at 40 and 90 ms; then predict what changes if B cannot communicate for the entire observation period. Related track: System Design (link pending actual catalog verification).
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Partial failure and consistency — knowledge check
Choose the best answer for each offline scenario.
A write finishes on A before a read starts on B, which returns an older value. Which guarantee is violated?
What does CAP exclude under the stated partition model?
For N=5, R=3 and W=3, what is the minimum overlap?
What distinguishes strict serializability from serializability?
A lease holder with token 7 resumes after token 8 has written. What protects the resource?