Lease
Also known as: distributed lease, job lease.
A time-limited grant to use a resource or perform work; the holder must renew it, and others may proceed after it expires.
Synthetic dataExamples on this page use synthetic data created for illustration.
Definition
A lease is a time-limited grant to use a resource or perform a piece of work. The holder renews it while making progress; if renewal stops and the lease expires, another participant may proceed. Leases bound how long the system must trust a silent participant.
In plain terms
A permanent lock can remain stuck when its owner crashes. A lease adds an expiry time. The holder says “I still have this” before the deadline; silence eventually releases the claim without requiring the system to prove whether the holder is dead, disconnected or merely slow.
Expiry does not make the old holder disappear. A delayed worker may wake up after another worker has taken over. For that reason, systems commonly pair leases with attempt identifiers, fencing tokens or checks that reject stale writes. Jobs also need Idempotency because two attempts can overlap around the expiry boundary.
Example
A worker claims job J at 10:00 with a 60-second lease and renews every 20 seconds.
| Event | Time | Consequence |
|---|---|---|
| Worker claims J | 10:00:00 | Lease expires at 10:01:00 |
| Renewal succeeds | 10:00:20 | Expiry moves to 10:01:20 |
| Worker loses its connection | 10:00:31 | No more renewals arrive |
| Lease expires | 10:01:20 | J may be claimed by another worker |
The recovery delay is bounded by the lease duration. A shorter lease detects failure faster but needs more frequent renewals and is more sensitive to pauses and network delay.
Common misunderstandings
- “Expiry proves the holder stopped.” It proves only that renewal was not observed in time; the old holder may still be running.
- “A lease prevents duplicate execution.” Near expiry, an old and a new holder can overlap. The result path must detect stale attempts or tolerate duplicates.
- “The shortest lease is safest.” Very short leases increase renewal traffic and false expiry; the duration must allow for expected work and communication delays.
References
- Cary G. Gray, David R. Cheriton. Leases: an efficient fault-tolerant mechanism for distributed file cache consistency . ACM SIGOPS Operating Systems Review, 1989. DOI: 10.1145/74850.74870