Systems & Backend

Lease

A lock with an expiry: a node holds a resource only for a bounded time, so a crashed holder cannot block others forever.

A lease is a lock with a time limit: a node is granted exclusive access to a resource for a bounded duration and must renew before it expires. If the holder crashes or is partitioned, the lease simply lapses and someone else can take over — no manual cleanup.

Worked example: a leader holds a lease and heartbeats to renew it every few seconds; if it dies, the lease expires and the cluster elects a new leader without waiting on the dead one. Gotcha: leases assume roughly synchronized clocks and bounded pauses — a long GC pause or clock skew can let a holder believe it still owns a lease that has actually expired, which is exactly why safety-critical uses pair leases with fencing tokens.