Unit 5 of 12 · about 4 hours · explain, implement

Unique identifiers, incarnation numbers and restart-safe identity

Every dedup key, fencing check and membership entry names an actor. A reused identity turns an ordinary restart into a split brain.

You'll be able to

  • Choose an ID scheme, random, wall-clock-ordered or Lamport pair, and state its collision, ordering and coordination costs.
  • Assign incarnation numbers so a restarted process never reuses a live identity, and say who may increment them.
  • Persist the identity state that makes restart safe, and test the dual-incarnation case.

Covers

Unique identifier collision and ordering propertiesNode, process and client incarnation identifiersRestart-safe identity persistence
1

Read

In this order, only the parts listed

0 of 3 done

  1. ID generators and Lamport pairsDDIA 2e - Chapter 9 The Trouble with Distributed Systems

    Chapter 10, ID Generators and Logical Clocks: autoincrement and linearizable single-node IDs, random UUIDs and wall-clock timestamp schemes (pp. 417-419); Lamport (counter, node ID) pairs with the Aaliyah, Bryce and Caleb ordering and Figure 10-9 (pp. 420-421)

  2. Incarnation numbers against false suspicionSWIM: Scalable Weakly-consistent Infection-style Process Group Membership (Das et al., 2002)

    Section 4.2, Suspicion Mechanism: incarnation initialized at join, incremented only by the suspected node itself; Alive refutes older Suspect, but Confirm overrides Alive and Suspect at any incarnation

  3. Unique IDs under partitionGossip Glomers - Unique IDs and Broadcast

    Challenge 2: generate with any ID type under partition with total availability; run ./maelstrom test -w unique-ids --bin ~/go/bin/maelstrom-unique-ids --time-limit 30 --rate 1000 --node-count 3 --availability total --nemesis partition with the binary path pointed at your own node; uniqueness is checked, ordering and monotonicity are not

2

Focus on

  • Single-node autoincrement is linearizable: an insert that completes before another begins gets the smaller ID. No distributed scheme in this unit keeps that without coordination.
  • Random 128-bit IDs need no communication and give no order. Wall-clock schemes sort roughly but lean on NTP, a shard or random part, and a per-shard sequence for same-millisecond uniqueness.
  • A Lamport pair is unique when node IDs are unique, and orders causally but not by wall time. Two nodes that never communicate can hold wildly different counters.
  • Only the suspected member increments its SWIM incarnation; a higher Alive refutes older Suspect, but the original paper's Confirm is terminal for that member identity. Separately, persist an ID epoch before using it and advance it durably on restart, so new IDs cannot collide with pre-crash IDs.
Common mistakes · 3
  • Reading wall-clock ID order as causal order. A fast clock stamps an earlier write above a later one from a slow clock, and one NTP step reorders a single node's IDs.
  • Letting another node bump a member's incarnation. Only the member itself increments; anything else lets a node that never heard from the member refute its suspicion.
  • Rejoining with the same identity and a reset counter. The group still holds the old incarnation, so rejoin as a new epoch or a new member, never as a silent reset.
3

Try it yourself

Closed-book, before checking anything

Closed-book, show the restart hole: node B issues (counter 1..50, node B), crashes without persisting, restarts at counter 0 and reissues counter 1, colliding with a live record. Then fix it: persist an epoch that increments once per restart, so post-restart IDs read (epoch 2, counter 1) and never equal epoch 1 IDs.
4

Quiz yourself

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

0 got · 0 missed

  1. 1.A billion random version-4 IDs are generated. About how likely is one collision?Answer

    About . With 122 random bits the birthday term is near , vanishingly small but not zero, and it says nothing about order.

  2. 2.Two Snowflake IDs sort correctly. Does the earlier-sorting record causally precede the other?Answer

    Not proven. Sort order follows wall clocks plus shard and sequence parts; skew or a step can invert it relative to causality.

  3. 3.Node X is suspected at incarnation 3, then broadcasts Alive at incarnation 4. A late Suspect for incarnation 3 arrives after. What does the group keep?Answer

    Alive at 4. The higher incarnation wins, and the stale report for 3 is dropped.

  4. 4.Why must the epoch live on stable storage rather than in memory?Answer

    Memory resets on crash, which replays epoch 1. Stable storage survives, so the next boot provably moves to epoch 2.

5

Practice

  • Gossip Glomers 2: Unique ID Generation

    Run ./maelstrom test -w unique-ids --bin ~/go/bin/maelstrom-unique-ids --time-limit 30 --rate 1000 --node-count 3 --availability total --nemesis partition with the binary path pointed at your node; keep the run directory

    Maelstrom runs local processes over a simulated network, but this challenge does not test restart. The section mini-project covers this: issue IDs, restart with the same durable state, issue more, and check uniqueness across both batches.

You're done when

The challenge passes, your separate restart test has no duplicate across both batches, and you can name the durable state that prevents reuse.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 11 more in the section
  • DDIA 2e - Chapter 9 The Trouble with Distributed SystemsMartin Kleppmann and Chris Riccomini · primary

    Read clocks, pauses, unreliable networks, partial failures and knowledge limits. For each failure, record what a node observes, what is true globally and what action is safe under that uncertainty.

  • SWIM: Scalable Weakly-consistent Infection-style Process Group Membership (Das et al., 2002)Cornell University · support

    Read the direct and indirect probing detector, infection-style dissemination, the suspicion mechanism and incarnation numbers. Suspicion timeouts depend on the workload.

  • Gossip Glomers - Unique IDs and BroadcastFly.io and Jepsen · required

    Each challenge runs locally under Maelstrom (v0.2.4; the pages were tested on 0.2.3) with its checker and, where the page says so, the partition nemesis; keep the run directory as the history. Do challenge 2 (unique IDs under partition with total availability) and 3a to 3c (broadcast, then with partitions). A pass shows uniqueness or convergence in that run, not ordering or recency.

Also in this section