Skip to content

Recovery reconcile runtime

Every watch a node performs can return one of four situations: ordinary progress, a control plane asking for a resync, a revision lower than the one the node holds, or a node that already knows its own cursor failed its checks. The recovery reconcile runtime is the one place those are turned into a single decision, before anything is applied.

It reads three values and returns one document, and the cycle applies that document in one step.

The decision

flowchart TB
  IN["Current revision,<br/>watch response,<br/>corruption condition"]
  C1{{"Corruption held<br/>by the node?"}}
  C2{{"resync_required<br/>in the response?"}}
  C3{{"Returned revision lower<br/>than the current one?"}}
  R1["Resync to the snapshot revision,<br/>reason: cursor corruption"]
  R2["Resync to the snapshot revision,<br/>reason: from the control plane"]
  R3["Resync to the returned revision,<br/>reason: cursor gap"]
  R4["Target the greater of<br/>current and returned"]
  IN --> C1
  C1 -->|"yes"| R1
  C1 -->|"no"| C2
  C2 -->|"yes"| R2
  C2 -->|"no"| C3
  C3 -->|"yes"| R3
  C3 -->|"no"| R4

The order gives the node's own corruption condition priority: a node that cannot trust its cursor resyncs whatever the control plane said. Target the greater of current and returned is the ordinary path, and it is also the path a failed watch takes, because a failed watch returns the current revision.

The inputs

Input Source
current_watch_revision The node's live position
watch_response The control plane's answer, carrying resync_required, snapshot_revision, next_revision, resync_reason_code and items
cursor_corruption_detected The watch cursor owner's condition flag

Absent fields fall back without raising: snapshot_revision defaults to the current revision, and next_revision defaults to the snapshot revision. A response with none of the three leaves the position where it was.

The answer

{
  "contract_version": "system.recovery_reconcile_runtime.contract.v1",
  "resync_required": true,
  "reason_code": "CURSOR_GAP_DETECTED",
  "current_revision": 812,
  "target_revision": 806,
  "items": []
}
Field Means
resync_required The position is being restored from the control plane
reason_code Empty, ASSIGNMENT_CURSOR_CORRUPTION_DETECTED, or the gap reason
current_revision Where the node was
target_revision Where the node will be
items The assignments carried in the response, snapshot or delta alike

The cycle applies the answer in one step: if the target differs from the current position it sets and persists the new position, and if a resync was required while the node held a corruption condition it clears that condition. One watch produces one position change.

Reason codes

(empty)                                 ordinary progress
ASSIGNMENT_CURSOR_CORRUPTION_DETECTED   the node's own cursor failed its checks
ASSIGNMENT_CURSOR_GAP_DETECTED          a resync with no reason from the control plane

A reason the control plane supplied is carried through as it arrived, so CURSOR_GAP_DETECTED from the dispatch recovery contract reaches the node's logs with the control plane's own wording.