Skip to content

Resuming assignment processing after a crash

A node that stopped mid-assignment comes back with its stream position intact and its local claims stale. This page covers where processing picks up: which assignments arrive again, which are repeated, and the order the node has to do things in before it may take work at all.

The order

flowchart TB
  subgraph VOL["NODE VOLUME"]
    direction TB
    IDS[("Identity state")]
    CUR[("Watch cursor")]
  end
  subgraph PROC["NEW XRATUD PROCESS"]
    direction TB
    BOOT["Startup"]
    LREC{{"Lease recovery"}}
    IDG{{"Identity freshness gate:<br/>claims allowed?"}}
    WRK["Workers"]
  end
  subgraph CP["CONTROL PLANE"]
    direction TB
    REGN["Registration"]
    LED[("Assignment ledger<br/>leases, fence epochs")]
  end
  IDS -->|"1. identity and binding"| BOOT
  CUR -->|"1. position"| BOOT
  BOOT --> LREC
  LREC -->|"2. stale claims expired"| WRK
  BOOT -->|"3. register"| REGN
  BOOT --> IDG
  IDG -->|"4. allowed: watch<br/>from the position"| LED
  LED -->|"5. lapsed and leased<br/>assignments"| WRK
  WRK -->|"5. claim, work, report"| LED

The node takes its identity and position from NODE VOLUME and clears its own stale claims before it registers, so it never competes with its previous process. Identity freshness gate decides whether the node may watch at all, and everything it then works on comes from Assignment ledger.

What arrives again

Assignment state when the node stopped What happens
Claimed, not started The ledger lease lapses and the control plane dispatches it again
Started, no terminal status reported The ledger lease lapses, it is dispatched again, and the work runs a second time
Completed, terminal status reported and acknowledged Finalized on the ledger, and nothing arrives
Completed, terminal status staged and not acknowledged The ledger lease lapses and it is dispatched again

In the second and fourth rows the work runs again: the dedupe record that would have recognised the repeat belonged to the previous process. See Idempotency and replay-safe reprocessing.

What bounds the repetition

A build resolves to the same content-addressed artifact and its publication is recognised at the registry. A deployment reconciles to a state that already matches. A closure resolution finds its entries already in the node's content store and verifies them in place.

Runs stay in the kernel. A project runtime executes its own agents and workflows, and a run in progress continues through a node restart. The kernel holds its evidence and the node resumes collecting it. See What the kernel does while the link is down.

Where the position comes from

The reloaded cursor is the position the node watches from. Three outcomes follow:

cursor valid and at the stream        the node continues from where it stopped
cursor valid and behind the stream    the node reads the range it missed
cursor refused or past the stream     the control plane answers with a snapshot
                                      of every assignment the node still leases

The third case is the one that restores a node whose volume was lost. The snapshot carries the assignments in an active status whose lease the node holds and which have not expired, so the node resumes with its real workload. See Gap handling.

Verifying the resume

A resumed node shows four things:

Check Expected
The lease recovery log event Present once with its counts when the start inherited claims; absent after a clean start
The registry's lease_recovery entry executed true
The node's watch revision Advancing, and at or under the control plane's stream revision
Runtime identity state healthy

A node whose identity stays in quarantined without a recovery transition is the stop condition for a DP restart. See Mass restart recovery.