Highlights

Contents

Part VI
06

Eventual consistency and quorums

We distinguish replica count from the ordering promised to readers. An overlapping read and write set can still lack a complete agreement protocol. We will trace delayed versions, deletions, repair, and the exact statement made by quorum arithmetic.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Access-pattern-drivendesign2Key-value stores: Redis,DynamoDB3Document stores: MongoDB4Wide-column: Cassandra,Bigtable5Graph databases and SQLvs NoSQL6Eventual consistency andquorums7Case study: a completedata model

#Section 26Eventual consistency and observable lag

A clip owner edits a title, but Heron’s search page still shows the old text. Eventual consistency promises convergence under the system’s delivery and repair assumptions after relevant updates stop. It does not, by itself, promise a maximum delay or require every reader to observe the same intermediate version.

Follow one change. The authoritative owner commits it, a propagation path records it, a consumer receives it, and the derived view applies it. A failure can occur between any of those states. A correct design knows whether to retry, replay, compare versions, or rebuild after that failure.

For an illustrative event rate of 20 per second, five seconds of propagation delay correspond to 100 events behind if rates are constant. That converts lag into a workload count, but it does not establish the actual view is exactly five seconds old. Measure source progress and consumer progress using comparable positions or timestamps.

Choose how readers behave during lag. A clip editor may read directly from the authoritative owner after saving. A recommendation page may permit a stale view. A delete-sensitive query may need stronger treatment. State the acceptable behavior per operation instead of treating “eventual” as a permission for any outcome.

THE VIEW IS 5 S BEHIND: 20 EVENTS/S × 5 S = 100 EVENTS NOT YET APPLIEDTHE VIEW IS 5 S BEHIND: 20 EVENTS/S × 5 S = 100 EVENTS NOT YET APPLIEDview positionsource position100 events = 5 s"eventually consistent" says nothing about how long; measure the gapeditor after save: read the owner. recommendation page: lag is fine
Figure 4.28Computed illustrative five-second delay at 20 events/s corresponds to 100 unapplied events.

#Section 27Versioned application and out-of-order delivery

The view receives version 8 and then a delayed retry of version 7. Blind replacement moves it backwards. A version is an ordering identifier within a defined authority. A derived view should compare source versions and reject older state when its update contract represents replacement by newer state.

Store the value and its version in the same atomic update boundary. First check the incoming identity, then compare its source version, then apply the new value and progress marker. If those steps can split across failures, a consumer may record progress without storing the change or store a change without knowing it completed.

A monotonic sequence assigned by one match owner works for that match’s state. It is not automatically a global order across unrelated matches or independent writers. Wall-clock timestamps can also disagree because clocks differ or several operations share a timestamp. State who assigns the order and how conflicts are represented.

Replay should be safe. Reapplying the same replacement version can be a no-op, but reapplying an increment can add the effect twice unless the event identity is deduplicated. Heron should distinguish snapshots from operations. The update type determines whether version comparison, event deduplication, or explicit conflict resolution is needed.

A VERSION CHECK ACCEPTS 8 AND REJECTS THE DELAYED 7A VERSION CHECK ACCEPTS 8 AND REJECTS THE DELAYED 7v8 sent firstv7 delayedviewstored v8v8v77 < 8: rejectreplacing with the same version is a no-op; an increment needs event dedupe
Figure 4.29Illustrative replacement view accepts source version 8 and rejects delayed version 7.
APPLY FIRST, THEN ADVANCE PROGRESS; A CRASH BETWEEN THEM ONLY CAUSES A SAFE REPLAYAPPLY FIRST, THEN ADVANCE PROGRESS; A CRASH BETWEEN THEM ONLY CAUSES A SAFE REPLAYe41e42e43e44e45source logconsumerview1 apply2 save "done to e43"crash after 1, before 2: e43 is re-sentthe conditional apply sees it is already present and does nothing
Figure 4.30Illustrative apply and progress marker must preserve a recoverable boundary under consumer failure.

#Section 28Tombstones and stale resurrection

A moderator deletes a clip, then an old title update arrives. If the delete simply removed every trace of the record, the update may recreate it. A tombstone is a retained deletion marker that carries enough identity or order to reject older state.

In Heron’s illustrative trace, replacement version 8 is followed by deletion version 9. A delayed version-7 or version-8 update must remain older than the version-9 tombstone. A legitimate new record needs a defined new identity or a newer authorized recreation operation. The consumer must not infer permission to recreate from the absence of visible data.

Tombstones have a cleanup problem. Retaining them forever costs storage, but removing one too early lets a long-disconnected replica or delayed retry resurrect the old record. Safe removal depends on replay retention, repair progress, and the maximum supported disconnected interval, rather than a convenient arbitrary expiry.

Deletion may need to reach indexes, graph edges, caches, and backups under their own policies. A base-record tombstone does not automatically remove search visibility. Keep deletion progress observable and verify the relevant derived paths. A design that can create several copies must also explain how those copies stop presenting a deleted fact.

A VERSION-9 TOMBSTONE BLOCKS A DELAYED VERSION-7 UPDATEA VERSION-9 TOMBSTONE BLOCKS A DELAYED VERSION-7 UPDATEv8 recordtombstone v9late v7 updatewithout the tombstone, the empty key would accept v7and the deleted fact would come backpurge the tombstone only after every replay older than v9 is impossibleand indexes, caches and graph edges have seen the delete
Figure 4.31Illustrative version-9 deletion blocks older delayed updates; cleanup needs a replay and repair boundary.

#Section 29Repair and rebuild are mechanisms

A consumer crashes after missing an update, so the derived score stays old. Repair detects and corrects disagreement with an authoritative source. Rebuild creates a replacement view from a known source boundary. Waiting alone does neither unless a delivery path actually resumes the missing work.

A repair process can compare source and view versions for known keys, replay a range from a checkpoint, or compare partition summaries before inspecting mismatches. Each choice trades bandwidth, detection delay, and source load. Record enough identity and progress to know which repair operation is valid.

For Heron’s illustrative hour of 72,000 events at 200 bytes each, a full payload replay transfers 14,400,000 bytes. At an assumed payload rate of 1,000,000 bytes per second, transfer alone takes 14.4 seconds. Parsing, index work, persistence, and ongoing updates can make actual rebuild longer.

A 100-event backlog replayed at 40 events per second while 20 new events continue arrives at spare rate 20. Drain time is five seconds. Capacity planning must reserve that catch-up work; otherwise a view that keeps pace during normal operation cannot recover from even a brief outage. The performance unit derives the same spare-service rule.

APPLY 40/S WHILE 20/S ARRIVE: 20/S SPARE CLEARS 100 WAITING IN 5 SAPPLY 40/S WHILE 20/S ARRIVE: 20/S SPARE CLEARS 100 WAITING IN 5 Snew events 20/s100 waiting (each = 5)40/sview40 − 20 = 20/s spare; 100 ÷ 20 = 5 sa view that only keeps pace can never catch up after an outage
Figure 4.32Illustrative 100-event lag drains in five seconds using 20 events/s of spare replay capacity.

#Section 30Quorum reads, writes, and replication factor

Heron stores a logical record on three fixed replica members. Replication factor NN counts those copies. A write waits for WW acknowledgements; a read asks RR members. A quorum is a required participating set, but its useful guarantee depends on the protocol around that set.

With N=3N=3, W=2W=2, and R=2R=2, the read and completed write sets overlap by at least R+W−N=1R+W-N=1 member. For example, write members A and B intersect read members B and C at B. The arithmetic assumes the same fixed membership and the acknowledged write set actually satisfies the stated write boundary.

R+W>NR+W>N

Read this as: read count RR plus write count WW exceeds replica count NN, ensuring intersection under the fixed-set assumptions. Intersection alone does not order concurrent writes, explain incomplete writes, or tell the reader which version to select. It also does not define whether an acknowledgement means persistence.

The illustrated quorum size of two can proceed with one unavailable member if the remaining members communicate and the rest of the protocol permits the operation. More copies increase storage and repair work, not automatically freshness. The original Dynamo paper describes reconciliation and membership behavior that must be understood alongside read and write counts.

READ AND WRITE SETS OVERLAP AT A REPLICA UNDER FIXED MEMBERSHIPREAD AND WRITE SETS OVERLAP AT A REPLICA UNDER FIXED MEMBERSHIPABCwrite setread setW = 2, R = 2, N = 3; R + W > Nintersection alone does not establish a complete consistency protocol
Figure 4.33Computed illustrative fixed sets intersect at B; membership and version-selection assumptions are part of the claim.