Unit 3 of 14 · about 4 hours · explain, implement

Failover, stale-leader risk and replica rejoin and replacement

The earlier units on incarnation numbers and on leases and fencing tokens built the identity and authority checks. Here the test is whether those boundaries survive promotion, divergent logs and replica replacement, not whether a timeout elects a leader.

You'll be able to

  • Construct a failover history that loses an asynchronously acknowledged write.
  • Implement a snapshot-position and suffix catch-up path for a replacement replica.
  • Reject stale authority and distinguish a returning replica from an empty replacement.

Covers

Failover and stale-leader riskReplica rejoin and replacement
1

Read

In this order, only the parts listed

0 of 1 done

  1. DDIA, 2nd edition: bootstrap, catch-up and promotionDDIA 2e - Chapter 6 Replication and Chapter 10 Consistency Sections

    Chapter 6, Replication: Setting Up New Followers, pp. 201 to 202; Handling Node Outages, pp. 204 to 206; Chapter 10, Consistency and Consensus: Implementing Linearizable Systems, pp. 411 to 413

    Skip the object-storage architecture sidebar on pp. 202 to 203. Read the Chapter 10 passage for stale-leader and lost-write boundaries, not a consensus implementation.

2

Focus on

  • A snapshot needs an exact position in a particular log lineage. Copying files while writes continue is not a consistent bootstrap procedure.
  • A replica missing retained history needs a new snapshot. A replacement must not inherit the old process's acknowledgements merely by reusing its address.
  • A timeout supplies suspicion, not exclusive authority. In this model, an explicit controller changes the epoch and the mutation boundary enforces it; distributed election comes later.
  • A rejoining old leader may carry an acknowledged but unreplicated suffix. Preserve that evidence before discarding, reconciling or rejecting it according to the contract.
Common mistakes · 3
  • Treating the largest numeric offset as freshest when two leaders have different log lineages.
  • Generating a higher epoch locally without an authority that prevents competing promotions.
  • Letting an empty replacement count toward a quorum before transferring the data that earlier acknowledgements depended on.
3

Try it yourself

Closed-book, before checking anything

Using Python 3 and an explicit controller, acknowledge a write on the old leader while replication is blocked. Promote a follower that lacks it, then read the old value. Record the resulting linearizability violation. Rejoin the old leader with its divergent suffix: block its writes using the current epoch, preserve the discarded suffix in the evidence, and rebuild it from a consistent snapshot plus the new leader's suffix. Repeat bootstrap with an empty replacement and with a gap in retained history; require a fresh snapshot for the gap.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Does fencing the old leader recover its lost acknowledged write?Answer

    No. Fencing prevents future stale-authority effects. It cannot supply data that the promoted follower never received.

  2. 2.Why must a snapshot carry its replication-log position?Answer

    The new replica needs to know exactly where replay begins. Otherwise it may omit updates or apply updates already reflected in the snapshot.

  3. 3.A follower requests a suffix that has been deleted. Can it safely skip to the current end?Answer

    No. That would omit state changes. Transfer a consistent snapshot and then replay the retained suffix belonging to it.

You're done when

Your tests expose the lost-write history, reject the stale leader, and rebuild both a returning replica and an empty replacement without skipping a log gap.

Only when you can do this without notes.

Leads to

Notes

Resources · 1 for this unit, 15 more in the section

Also in this section