advanced24 min studyLesson 236 in Engineering

Bound a lease using explicit clock assumptions

Derive a conservative duration comparison while distinguishing lease authority, process pauses, delayed operations, and safe resource access.

On this page

What you’ll understand

  • State which rights expire and which clock measures the duration.
  • Derive a conditional holder-duration bound from clock-rate limits.
  • Explain why pauses, restart state, and in-flight work require more than a local expiration check.

A lease grants specified rights for a limited time, allowing a service eventually to recover authority when a holder disappears. The word limited hides the essential questions: whose clock measures the term, when does that measurement begin, and what prevents an old holder from acting afterward? A correct design turns those questions into an explicit protocol. We will derive one deliberately narrow duration rule, then examine the operational events that can invalidate its assumptions or escape its scope.

Define the grant, the holder, and the clock

A lease is not simply a cached boolean saying that a lock was acquired. It grants a named holder particular rights over a resource under stated expiration and renewal rules. The grantor must not give incompatible rights to another holder while the original grant can still be valid. The holder must stop exercising those rights according to a conservative interpretation of its own timer. Record grant identity, scope, term, and the event that begins each timer. Comparing two printed absolute timestamps without a shared clock-error contract is not an adequate substitute for this state model.

Duration-based protocols can use bounded clock rates without requiring identical clock offsets. For a local elapsed clock advancing between 1−rho and 1+rho times physical rate, a measured duration can finish earlier or later in real time. A safety argument compares the holder's latest possible stopping time with the grantor's earliest possible expiration time. Define suspension behavior too: a timer that excludes a long process or machine suspension may not measure the passage of time relevant to a remote grantor. A local monotonic API protects certain ordering properties, but its name alone does not establish every lease assumption.

L1+ρ≤Tphysical≤L1−ρ,0≤ρ<1\frac{L}{1+\rho}\leq T_{\mathrm{physical}}\leq\frac{L}{1-\rho},\qquad 0\leq\rho<1
A clock accumulating L local seconds at a rate within 1±rho takes a physical duration in this interval. This assumes the rate bound holds continuously, including the relevant pause/suspend behavior, and no unaccounted jumps occur.↔ Scroll wide equations horizontally.

Derive one conservative rule rather than memorizing a TTL

Consider a specific simplified protocol. The holder starts its timer when sending the grant request, before the grantor can begin its own grant timer. The grantor's local term is Ls; the holder uses a shorter local term Lc. With holder rate error bounded by rho_c and grantor rate error by rho_s, the holder must stop no later than its slow-clock worst case. The grantor can expire as early as its fast-clock worst case. Requiring the former duration not to exceed the latter gives a conservative inequality, helped by the holder's timer starting earlier.

This is an illustrative rule, not a universal implementation prescription. A different timer-start event or a protocol based on bounded absolute-time intervals requires its own derivation. A delayed grant reply can arrive after the holder's conservative term has already ended; receiving the reply does not revive that expired interval. Renewals must specify which grant they extend and must not be accepted ambiguously after authority changes. A grantor restart or failover also cannot simply forget outstanding leases and issue conflicting grants. Durable grant state, an appropriate recovery wait, or another proven mechanism is part of the safety argument.

Lc1−ρc≤Ls1+ρs⟺Lc≤Ls1−ρc1+ρs\frac{L_c}{1-\rho_c}\leq\frac{L_s}{1+\rho_s}\quad\Longleftrightarrow\quad L_c\leq L_s\frac{1-\rho_c}{1+\rho_s}
Terms are local elapsed seconds. This sufficient bound applies only to the stated request-send holder start, later grantor start, continuous rate limits, and cooperative holder behavior; margins must also cover any modeled processing requirements.↔ Scroll wide equations horizontally.

Expiration does not retract an already issued operation

Even if the holder checks its timer before issuing a write, the process can pause afterward or the request can remain delayed in a network. The protected resource may observe that old operation after another holder has acquired authority. A lease argument about when a client issues work does not automatically prove when the resource applies it. Depending on the resource and protocol, validation at the resource, fencing, bounded operation completion, or another explicit mechanism is needed. Similarly, a holder that resumes after a long pause must re-establish its current authority rather than act on a stale in-memory assumption.

The replica instrument shows only one availability ingredient. For each separate configuration, Reset, set both replica count n=5 and unavailable count k, predict the available count and majority, then inspect. Compare k=2 with a fresh k=3 configuration. Three available replicas form a numerical majority; two do not. This diagram contains no grants, clock drift, quorum-vote history, or expiration rules. A majority being reachable can enable a correctly designed authority service to progress, but cannot by itself prove that an old lease expired or that an in-flight operation is rejected.

Compare worst-case local durations

In the simplified request-send-start protocol, the grantor term is 1000 ms. Both clocks have rate-error bounds rho=0.001. Choose a holder term 990 ms. Ignore other overhead only for this numerical exercise. Does the holder’s latest expiration precede the grantor’s earliest expiration?

  1. The fastest allowed grantor clock expires after 1000/1.001≈999.001 physical ms from its own start. This is the earliest grantor expiration under the rate model.

  2. The slowest allowed holder clock reaches 990 local ms after 990/0.999≈990.991 physical ms from its earlier request-send start.

  3. The holder duration is about 8.010 ms shorter even if the starts coincided; starting before the grantor only strengthens this particular comparison. Delayed operations and grant-state recovery still need separate protection.

The result

The selected local terms satisfy the conditional rate-bound inequality. This proves only the stated timer relationship, not end-to-end exclusion for arbitrary delayed writes.

Explore the model

Interactive lab

Interactive lab · reliability

Reachability does not certify lease expiration

For each separate view: Reset, set both n=5 and unavailable k, predict majority availability, then inspect. Compare k=2 with a fresh k=3 view. The model computes available=n−k and majority=floor(n/2)+1; it does not run a lease or consensus protocol.

Reachability does not certify lease expirationA replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Current readings: Available replicas: 4 of 5; Majority needed: 3; Majority available?: Yes. All parameters are adjustable with the labeled controls below.Majority available · need 3 of 5Playback highlights fixed statesR1 · upR2 · upR3 · upR4 · upR5 · downCyan mark: majority threshold
AvailableUnavailableMajority threshold
Available replicas
4 of 5
Majority needed
3
Majority available?
Yes
t = 0 s

A replica count and a majority threshold, without a consensus protocol. Playback highlights fixed replica states. Having a majority alone does not establish linearizability, durability or failure independence. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forThree reachable replicas versus two changes majority availability. That count alone proves neither grant exclusivity nor the expiration of an old holder’s authority.

Check your understanding

A holder checked its unexpired lease, issued a write, and then paused while the network delayed that write. A new holder later acquired a valid lease. What is still required?

Try it yourself

Under the same simplified timer-start assumptions, Ls=10 s and both rate-error bounds are 0.01. Compute the maximum holder term from the inequality and assess a chosen 9.8 s term.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use 10×0.99/1.01; this is an intentionally exaggerated rate bound for arithmetic.

Compare with the solution

The upper bound is approximately 9.80198 local seconds. Choosing 9.8 seconds is within it under the stated model. This duration comparison does not account for unmodeled pauses, resource-side delayed effects, or lost grant state.

Take it with you

  • Lease safety depends on named rights, timer start events, and explicit clock guarantees.
  • Conservative duration comparisons can use bounded rates without identical epochs.
  • Expired local authority, delayed effects, and grantor recovery need a complete protocol.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.