Skip to content

Fencing Token

Spicy — senior dev territoryArchitecture

ELI5 - The Vibe Check

Say a node holds a lease, but then it freezes for a while, its lease quietly expires, and a new leader takes over, and THEN the frozen node wakes back up, oblivious, and tries to keep writing as if it's still in charge. A fencing token stops this: it's a strictly increasing number handed out with each lease, and the storage system refuses any write carrying an older number than the last one it saw, even from a node that genuinely thinks it's still the boss.

Real Talk

A fencing token is a monotonically increasing number issued each time a lease or lock is granted, which downstream storage systems check and reject if a write arrives with a token older than the last one accepted. It solves the problem that a lease alone cannot guarantee mutual exclusion under pauses or clock skew, since a client can incorrectly believe it still holds a lease after it has actually expired, the fencing token check at the storage layer is what actually enforces correctness, not the lease timer itself.

When You'll Hear This

"Without fencing tokens, the zombie leader from before the GC pause could still corrupt data." / "Every write includes the lease's fencing token, storage rejects anything with a stale one."

Made with passive-aggressive love by manoga.digital. Powered by Claude.