Skip to main content

Module 3: Replication & Partitioning: Worked Examples

Example 1: Read-After-Write Fails on an Asynchronous Replica

Problem. A user updates a profile on the leader and is immediately routed to a lagging follower, which returns the old value.

Wrong first attempt. Retry any replica. Random retry does not establish that the chosen replica has applied the write.

Correct reasoning. Return a commit position or logical timestamp with the write. For that user’s subsequent reads, either route to the leader or choose a replica whose applied position is at least that token. Bound the session guarantee explicitly; do not claim global linearizability.

Why it works. The read is causally constrained by evidence that the replica has incorporated the preceding write.

Transfer question. What state must move with the user if the next request lands in another region?

Example 2: Quorum Arithmetic Is Necessary but Not Sufficient

With N=3, W=2, and R=2, W + R > N, so any successful read and write quorums overlap. That overlap helps a read observe at least one copy participating in the latest successful write.

Wrong first attempt. Conclude that every implementation is therefore linearizable. Sloppy quorums may write outside the home replica set, concurrent writes still need version ordering, and a coordinator can return stale data if it does not reconcile responses correctly.

Correct reasoning. State the assumptions: fixed replica set, successful durable acknowledgements, a rule for choosing the newest version, and read repair or equivalent convergence. Quorum equations describe intersection, not the whole consistency protocol.

Transfer question. Evaluate N=5, W=3, R=2; what guarantees change when W + R = N?

Example 3: Repair a Hot Partition

Problem. Hash partitioning by tenant_id places one very large tenant on one shard.

Wrong first attempt. Add more shards. The hot key still hashes to one shard.

Correct reasoning. Introduce controlled subpartitioning such as (tenant_id, bucket) for the heavy tenant, preserve a directory mapping tenant ranges to buckets, and fan out only queries that need the whole tenant. Migration needs dual-read or backfill checkpoints, idempotent copying, validation counts, and a cutover plan.

Transfer question. Which queries become more expensive, and can the product constrain them?

Completion Standard

  • Reproduce the stale-read timeline and implement a session-token remedy.
  • Explain quorum assumptions rather than quoting only R + W > N.
  • Design a hot-key migration with correctness evidence and rollback.