← Lessons

quiz vs the machine

Gold1430

Concurrency

The Lease Renewal

Granting time bound ownership that expires unless the holder keeps renewing.

5 min read · core · beat Gold to climb

Ownership with an expiry

A lease grants a node exclusive ownership of something for a fixed duration. Unlike a plain lock, a lease expires automatically. To keep ownership, the holder must renew before the deadline. If it crashes, the lease lapses and someone else can take over without manual cleanup.

Why leases beat locks

A plain distributed lock has a failure mode, a holder that crashes while holding it. The lock is stuck until an operator intervenes. A lease has a built in escape, time. Even if the holder vanishes, the lease expires on its own.

  • The holder acquires a lease valid for a window.
  • It renews periodically, well before expiry.
  • If renewals stop, the lease expires and is grantable again.

The clock skew danger

Leases depend on time, and clocks across machines disagree. A holder may believe its lease is still valid while the granter has already expired it. Safe systems renew with a generous margin and assume a lease could be gone earlier than the local clock suggests.

Key idea

A lease grants time bound ownership that lapses unless renewed, which cleanly recovers from crashed holders, but clock skew means holders must renew early and never assume their lease outlives the granter view.

Check yourself

Answer to earn rating on the learn ladder.

1. How does a lease recover from a crashed holder?

2. Why is clock skew dangerous for leases?

3. What must a lease holder do to keep ownership?