Linearizable reads: prove authority and wait for application
Trace a current-term commitment barrier, a fresh quorum confirmation, and an applied-index wait before serving a read without logging it.
On this page
The question for today
What you’ll understand
- Explain why a leader's local role flag cannot authorize a linearizable read.
- Follow ReadIndex through current-term commitment, fresh quorum confirmation, and application.
- Distinguish communication-based read safety from clock-dependent lease assumptions.
A server can keep answering reads after losing contact with the rest of the cluster. It may even still believe it is leader while a newer leader has committed updates elsewhere. Serving its local database is fast, but the result can violate a linearizable API. ReadIndex-style protocols avoid appending every read to the log while retaining a justified read boundary. The optimization has several prerequisites; a single heartbeat received sometime in the past is not a perpetual permission slip.
A read needs a point within its own interval
A linearizable read must correspond to a legal state at some point between its invocation and response, respecting writes completed before it began. It need not include every concurrent write that finishes before the response if a valid earlier linearization point exists. This distinction prevents an impossible requirement that the result remain newest while the response travels. What is unsafe is an old isolated leader returning state that already predates a completed write when the read was invoked.
One simple safe baseline treats a read as an ordered operation through the replicated log, then applies through its position before querying. A more efficient approach uses the leader's committed prefix and a quorum authority check. At the start of a term, the new leader can contain committed entries without yet knowing the full commitment boundary. It first commits an entry from its own term, commonly a no-op, so the earlier prefix is established before it uses the read optimization.
Fresh authority and applied state are separate gates
For an appropriately accumulated read request, the leader records a committed read index R and obtains a fresh quorum confirmation of its leadership in the relevant term. Requests and responses must be correlated so old acknowledgements cannot satisfy a newer read round incorrectly. The current-term commitment prerequisite and quorum check together establish a safe boundary under the protocol's assumptions. Batching can amortize one confirmation across requests accumulated before that round; it does not permit arbitrary future reads to reuse an indefinitely old confirmation.
Before querying, the serving replica waits until its state machine has applied at least R. A follower can serve the actual query only after obtaining a safe read index from the leader and catching its own state machine up to that boundary, under the implementation's protocol. Merely knowing that R is committed does not make unapplied state fresh enough. Snapshot installation, concurrent application, and query execution must expose a coherent state-machine view, so a query cannot observe half of an applied transaction.
Leases spend timing assumptions to save messages
A lease can reduce per-read communication by asserting a bounded period in which a newer leader cannot validly take over. That assertion requires a proved relationship between clock rates, election behavior, pauses, and lease expiry, not just synchronized-looking wall clocks. Leadership transfer can end the relevant authority earlier and must invalidate the lease appropriately. If clock or timing assumptions fail, the optimization can return stale reads even while the underlying log protocol remains safe. Prefer an explicit lease proof to treating a recent heartbeat timestamp as self-evident authority.
Use the queue lab for the application gate only. Reset, explicitly set arrival zero and service two, predict that four pending items drain in two seconds, then Play or Step. For a separate slower run Reset and explicitly set arrival zero and service one before predicting and playing. Rate changes retain elapsed time and recompute from four initial items, rather than preserving the old backlog. The animation has no quorum messages, read index, leader lease, or coherent database snapshot; it shows only how outstanding work can delay an already justified read boundary.
Work it through
Wait for the last three required applications
A leader has already committed an entry from its current term. A read begins at 10 ms; at 11 ms it records safe-candidate index 120 and begins the corresponding fresh quorum check. Quorum replies arrive by 16 ms. The serving replica has applied only through 117 and reaches 120 at 18 ms.
The quorum confirmation at 16 ms resolves the authority gate for this properly correlated round. It does not cause the state machine's applied index to jump from 117 to 120.
There are 120−117=3 required entries left to apply. The read must wait through their ordered application, reaching the required boundary at 18 ms under the given trace.
A coherent query at 19 ms with response at 20 ms can follow the established protocol. A reply at 16 ms from state 117 would skip the application gate, even though a quorum already confirmed the leader.
The first permitted query time in this trace is after application reaches 120, not merely after receipt of quorum replies. Additional implementation work can delay the response further.
The living notebook
Explore the model
Interactive lab · queue
A safe read can wait behind application
For separate drain experiments use Reset → explicitly set both rates → predict → Play or Step. Compare λ=0, μ=2 against Reset plus λ=0, μ=1; four initial items drain in two versus four seconds. Edits retain elapsed time and recompute from that initial backlog. This fluid model does not establish ReadIndex, authority, or lease safety.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. 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 forAuthority confirmation and state-machine freshness are distinct requirements; the animation illustrates only outstanding application work.
Pause & reason
Check your understanding
Your turn
Try it yourself
A read requires index 450 and the replica has applied 444. Assume no new required work and a constant two entries per millisecond after the authority check. What ideal drain time follows? Does knowing that a lease began five seconds ago establish that it is still valid?
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 outstanding indices and divide by the stated application rate. For the lease, identify the missing expiry and clock assumptions.
Compare with the solution
Six entries remain, giving an ideal three-millisecond application delay under the constant-rate assumption, before any separate query cost. This is a workload estimate, not a real-time guarantee. A lease's age alone proves nothing without its permitted duration, clock-rate bounds, election and transfer rules, and treatment of pauses. A local role flag or timestamp cannot replace those assumptions or a fresh communication-based read protocol.
Keep the idea
Take it with you
- An isolated leader can serve stale data unless the read protocol reestablishes authority.
- ReadIndex requires both a safe committed boundary and application through that boundary.
- Lease-based reads exchange communication for explicit timing assumptions.
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.