Committed state, reads and leadership
hard 7 minA replicated log gives nodes a shared sequence of state changes.
Video lesson · Chapter 1 of 4
An old leader serves an old value
Theory
Read or listen first. About 2 min.
What it is
A replicated log gives nodes a shared sequence of state changes. A leader may have a local entry before it is committed. Elections and commitment rules protect against two incompatible committed histories in the fault model. A read path also needs a way to establish freshness if it promises linearizability.
Why it exists
A recovered former leader responds quickly but returns yesterday’s setting to some clients. Its process is healthy, yet it may have missed a later term and committed writes. Compare term, commit position and the read protocol. A quorum-backed read or a properly specified lease can establish authority, while an explicitly stale read can serve a different product need.
If freshness was established, compare the entry’s commit and apply positions with the actual snapshot served.
An old leader serves an old value
Inside this chapter
- Strong Consistency (Linearizability)
- Linearizability gives each completed operation a point between invocation and response consistent with real-time precedence. It concerns observable histories rather than how frequently replicas exchange updates.
- Eventual Consistency
- Eventual consistency promises convergence under the system’s assumptions once updates cease and propagation progresses. It does not alone set a staleness bound for an individual read.
- Causal Consistency
- Causal consistency preserves dependencies such as observing a reply after its parent message. Independent concurrent writes need not appear in the same total order to all readers.
- Distributed Locking primitives (ZooKeeper/Etcd basics)
- A distributed lock grants temporary authority under a protocol. A paused former owner can resume after expiry, so protected resources may also need monotonically checked fencing tokens.
- Read-Your-Writes and Session Consistency
- Read-your-writes is a session guarantee. It can be implemented using version tokens or routing while unrelated sessions may observe older values under a weaker contract.
- Raft Consensus Algorithm
- Raft divides consensus into leader election, replicated logs and safety rules. A majority-backed current-term commitment rule protects the committed history across leadership changes.
- Paxos basics
- Paxos uses proposals and intersecting quorums to keep chosen values compatible. Production replicated logs usually add leadership, recovery and repeated instances around that core agreement.
- Leader Election Mechanisms
- Election timeouts suspect a failed leader but cannot prove a crash. Term or epoch numbers and quorum rules distinguish current authority from stale leadership beliefs.
- Gossip Protocols
- Gossip spreads membership or state through repeated peer exchange. It scales dissemination but normally gives a converging view, which is insufficient by itself for exclusive write authority.
How it works
Step through the idea, or press Play.
Elect a leader. Votes and log freshness rules establish authority for a term.
Understand it
Worked incident
An old leader serves an old value
| Observation | Stale results per 10 reads (reads) | Interpretation |
|---|---|---|
| Baseline | 0 | Reads go through the current authority. |
| Incident | 6 | A recovering node answers before establishing freshness. |
| After intervention | 0 | Gate strong reads on the protocol’s freshness condition and test across a leadership change. |
Choose the next investigation
Summary
The whole topic in one minute.
A partitioned node may not have observed a later election. The read path must account for newer committed state.
If freshness was established, compare the entry’s commit and apply positions with the actual snapshot served.