Try
↑ ↓ move↵ openesc close
In this lesson · topic 3 of 7
  1. 1. The lock that lies
  2. 2. Leases and fencing tokens
  3. 3. Trusting storage against token storage
  4. 4. What a 5-second lease and a clock check buy
  5. 5. When the lock's safety depends on the clock
  6. 6. Sessions, jeopardy and sequencers in a production lock service
  7. 7. Check the stale write

Topic 3

Trusting storage against token storage

7 min read

Two storages, one story

The lab starts in compare mode. Both sides see the same clients, the same lock service and the same stalls, from the same seed. Only the storage rule differs. Each panel shows who holds the lock and for how long, what every client is doing, and how many writes storage accepted, rejected, and accepted on top of a newer holder’s write. That last number is the one that matters.

Predict before you press play

After a minute, how do the two corrupting-write counters compare?

lease 1000 mswork ≈ 400 ms, then a 1500 ms stall on 25% of writesclocks run 0% slow

No fencing

Lock service. free

  • client 0idle0 ok
  • client 1idle0 ok
  • client 2idle0 ok

Storage. highest token seen 0 · last writer none

accepted
0
rejected
0
corrupting writes
0

    Fencing tokens

    Lock service. free

    • client 0idle0 ok
    • client 1idle0 ok
    • client 2idle0 ok

    Storage. highest token seen 0 · last writer none

    accepted
    0
    rejected
    0
    corrupting writes
    0
      Corrupting writes accepted over time

      Waiting for data. Press play or step the simulation.

      Full-page version with guided experiments: Locks, leases and fencing lab.

      Things to try

      1. Watch a client turn red. It stalled after checking its lease. Follow the next few seconds in both event lists.
      2. Set the stall length below the lease. Corruption stops on both sides, because the lock is never reassigned under a live client.
      3. Raise the lease to 5000 ms. Corruption nearly stops without fencing. Then watch how long clients wait every time a lease expires under a stalled holder.
      4. Set stalls to 0% and work to 900 ms with a 1000 ms lease, then raise clock drift. The client’s own lease check starts letting late writes through.
      5. Raise clients to 6. More waiters mean the lock is reassigned the instant it expires, so every stall overlaps a newer write.

      The full-page lab has five guided experiments with one-click setups.

      Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms