/ THE IDEA
Expiry solves a recovery problem: a crashed owner cannot hold a resource forever. It does not prove that every command from the previous owner has disappeared. A command may wait in a network queue or inside a paused program after the permission was last checked. A fencing token is an increasing number attached to each new grant of authority. The resource receiving writes remembers the greatest accepted number and rejects commands from older grants. The check happens where the effect is applied, not solely in the worker’s belief about whether it still owns the lease.
THE FORMAL IDEA
accept write only when token ≥ highest_seen
| token is the authority number carried with a write; highest_seen is the largest authority number accepted by that resource. ≥ means at least as large. | | The numbers must rise across ownership grants and be bound to legitimate grants, not freely chosen by writers. The resource must check and update its remembered value atomically, as one indivisible action. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
Worker A receives token 41, then pauses. Its lease expires. Worker B receives 42 and writes; the resource remembers highest_seen = 42. A resumes and sends 41. Since 41 < 42, the write is rejected. Change A’s arrival time: if 41 arrives before any 42, this simple test can still accept it.
|
The final change exposes the exact guarantee: older authority cannot write after newer authority has been observed. A fencing number by itself does not tell the resource what time a lease expired.
/ SO WHAT?
This is useful whenever recovery can leave a slow former owner alive. Checking the lease and then writing leaves a pause-sized gap between those actions. Moving authority validation into the destination closes the stale-after-newer path, provided every writing route participates. A strict policy rejecting all work after expiry needs an additional correctly enforced validity check, not a stronger-sounding description of the same counter.
ONE CAVEAT |
| Fencing requires cooperation from the resource and durable authority tracking. A service that accepts unlabelled writes bypasses the protection. Repeated commands from the current owner may still need separate duplicate-effect handling; ownership numbers are not unique operation identifiers. |
KEEP THIS
A timeout allows replacement; a destination-side authority check stops older owners overwriting work after newer authority has arrived.
|
NEXT: Why two equally sunny planets can differ in warmth
|