Skip to content

Leases held at crash time

An assignment in flight is held by two records at once: a lease on the control plane's assignment ledger, and a local claim in the node's own state file. A crash leaves both behind, and they are resolved differently. The ledger lease lapses on a clock the control plane owns. The local claim is cleared by the next process that starts.

This page covers both resolutions, the window between them, and the guard that keeps a returning process from acting on work it no longer owns.

The two records

flowchart TB
  subgraph CP["CONTROL PLANE"]
    direction TB
    LEASE[("Ledger lease<br/>owner, expiry, fence epoch")]
    EXP["Expiry sweep"]
    LEASE --> EXP
  end
  subgraph NODE["NODE STATE FILE"]
    direction TB
    CLAIM[("Local claim<br/>worker, status, expiry")]
    REC["Startup recovery"]
    REC --> CLAIM
  end
  ASG["Assignment in flight"]
  ASG --> LEASE
  ASG --> CLAIM
  EXP -->|"dispatched again"| ASG

Ledger lease is the authority over who may work on the assignment. Local claim makes the node's own workers exclusive with each other. Startup recovery is the only thing that resolves a claim left by a process that no longer exists.

What resolves each one

Record Resolved by Result
Ledger lease The control plane's expiry, at the lease TTL the node registered with The assignment returns to the dispatch queue
Local claim The next process's startup recovery, which expires every claim held by this worker id and sweeps due leases The claim becomes claimable again

The registered lease TTL is twice the node's heartbeat interval, with a floor of five seconds, so a node on the default 15 second heartbeat holds its registration lease for 30 seconds.

Recovery expires and keeps the record

Startup recovery moves a claim to expired with its expiry set to zero. The record stays, carrying its claim count, its creation time and its attempt, so the next claim on that assignment is recorded as a further hold on the same work. The counts are reported in the registry and in one log event. See Lease dedupe and finalize.

A release is the other ending, and it belongs to finalize: a release marks the assignment finished, and an expiry marks the hold as stopped.

The window between the two

A crash opens a window: the node's process is gone, and the ledger lease has not yet expired. During that window the assignment is held by a node that cannot work on it, and nothing else may take it.

The window closes on the lease TTL, so it is bounded by the heartbeat interval the node registered with. Shortening the heartbeat shortens the window and raises the pull and report rate against the control plane, which the deployment's rate limits bound. See Sizing and capacity planning.

A stale hold writes nothing

The fence epoch guards the window. A write carrying a superseded fence epoch fails closed and mutates no assignment state, so a process that was partitioned and comes back cannot finalize an assignment that has been dispatched to someone else in the meantime.

The same rule reaches the kernel: operator commands and return-lane acknowledgements are accepted only from the current owner at the current fence epoch, and a refusal stops the reconnect. See Ownership handover across a break.