2026 field guide

Refreshed for cloud-native, multi-region, streaming, and AI infrastructure.

Explore 41 concepts →
Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Consensusadvanced7 min read

Leases & Fencing Tokens

Grant temporary authority without allowing a paused or partitioned former owner to corrupt shared state.

2–5 minute refresher
Mental model

A lease suggests who owns authority; a fencing token lets the resource reject everyone older.

30second
refresher
A lease grants authority for a bounded interval. Because a holder may pause, lose connectivity, and resume after expiry, safe systems pair leases with monotonically increasing fencing tokens checked by the protected resource.

What problem does it solve?

Two workers can both believe they own a resource when one pauses past expiration or cannot observe renewal failure. Local clocks and process health cannot prove exclusivity.

How it works

  1. Acquire authority from a strongly consistent coordinator.
  2. Receive an increasing epoch or fencing token.
  3. Attach that token to every protected mutation.
  4. Have the resource reject stale tokens.
  5. Renew for liveness, but rely on fencing for safety.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
Short leaseFast failoverMore false expiry
Long leaseFewer renewalsSlower recovery
FencingRejects stale ownersEvery resource must participate
What happens if?

A paused owner wakes up

Worker A pauses after acquiring lease 41. Worker B obtains lease 42 and begins work. A resumes and writes successfully unless the resource compares fencing tokens.

Where it appears

  • Schedulers
  • Metadata leaders
  • Distributed locks
  • Object-store writers
Senior interview modeWhy is a distributed lock alone insufficient?Show answer
The coordinator can grant a new lock, but it cannot erase the old holder's memory or stop its network requests. Safety requires the resource receiving mutations to distinguish new authority from stale authority.
#leases#fencing#coordination#clock safety