techdiagrams.net
← All templates

Distributed lock service with fencing

Leases, heartbeats and fencing tokens over a consistent core — including the exact scenario where a GC-paused client gets fenced instead of corrupting data.

Open in editor — free, no login Download JSON
CONSISTENT COREacquire → lease + token 33heartbeat renew /5sacquire — queuedraft replicatewrite (token 33) ✓write (token 32) ✗ FENCEDWorker Aholds lease · token 33Worker Bqueued — waitingWorker A′ (GC-paused)stale · token 32Lock service (leader)lease 10s · mints tokensLock replicas ×2raft followersProtected resourceaccepts token ≥ 33the rule: a distributed lock is only assafe as the resource's token check.Lock + lease + fencing — all three,or you have a suggestion, not a lock.

What this design does

A distributed lock without fencing tokens is a false sense of safety: a client can hold the lock, pause for a GC or network blip, lose the lease, and keep writing. This diagram shows the whole defense — leases that expire, heartbeats that renew, a monotonic fencing token minted per acquisition, and the storage layer rejecting the stale token. It's also the honest version of the Redlock debate.

The patterns it composes

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.