Gap handling¶
A gap is the state where a node's recorded position claims more than the peer at the other end can account for. It happens on both inbound lanes, for different reasons, and both are resolved the same way: the node's position moves to what the peer can prove, and the peer supplies what the node is now missing.
This page covers how a gap is detected on each lane, what the node is given to recover with, and the reason codes each case produces.
Where a gap is detected¶
flowchart TB
subgraph CPL["CONTROL PLANE LANE"]
direction TB
CMP{{"since_revision greater than<br/>the stream revision?"}}
SNAP["Snapshot of active leased assignments<br/>plus a delta start revision"]
CMP -->|"yes"| SNAP
end
subgraph KL["KERNEL RETURN LANE"]
direction TB
ACK{{"Proposed sequence past<br/>the reported maximum?"}}
HOLD["Cursor held at its current value"]
ACK -->|"yes"| HOLD
end
NODE["Node position"]
NODE --> CMP
NODE --> ACK
SNAP -->|"position set to snapshot_revision"| NODE
HOLD -->|"position unchanged"| NODE
The two lanes differ in who notices. On the CONTROL PLANE LANE the control
plane compares the position the node sent against its own stream revision. On
the KERNEL RETURN LANE the node checks the kernel's proposal against the
maximum the kernel itself reported.
On the control-plane lane¶
The control plane compares the since_revision the node sends with the current
revision of that node's assignment stream. The answer is a snapshot and delta contract:
{
"resync_required": true,
"resync_contract_version": "system.dispatch_recovery_contract.v1",
"snapshot_revision": 806,
"delta_start_revision": 807,
"resync_reason_code": "CURSOR_GAP_DETECTED",
"since_revision": 812,
"next_revision": 806,
"items": []
}
items carries every assignment in an active status whose lease is held by this
node and has not expired, filtered to the workspaces the node targets. The node
takes snapshot_revision as its position and continues from
delta_start_revision. See
Recovery contracts.
What the node does with the answer¶
The node resolves one recovery action per watch, from three inputs: its own
corruption condition, the control plane's resync_required, and whether the
returned revision is lower than the one it holds.
| Condition | Resync | Reason code | Target position |
|---|---|---|---|
| The node holds a corruption condition | Required | ASSIGNMENT_CURSOR_CORRUPTION_DETECTED |
The snapshot revision |
The control plane set resync_required |
Required | The control plane's resync_reason_code, or ASSIGNMENT_CURSOR_GAP_DETECTED |
The snapshot revision |
| The returned revision is lower than the held one | Required | ASSIGNMENT_CURSOR_GAP_DETECTED |
The returned revision |
| None of the three | Not required | empty | The greater of the held and returned revisions |
The last row is the ordinary case, and it is also the rule that keeps a quiet or failed watch from moving anything: the greater of two equal values is the position the node already had.
A corruption condition clears once the resync it required has been taken, so the node holds it for exactly as long as it takes the control plane to answer.
On the kernel return lane¶
The kernel reports a next sequence and the maximum sequence it holds. The node checks the proposal against that maximum:
| Verdict state | Condition |
|---|---|
accepted |
At or under the reported maximum, and not behind the current position |
gap |
Past the reported maximum |
regression |
Behind the current position |
post_terminal |
Past the session's terminal sequence |
A gap verdict leaves the cursor where it was, so the node asks for the same
range again on its next drain. The kernel compacts what it has been told was delivered, so an acknowledgement
covers only envelopes that arrived. See
Cumulative acks.
The reason codes¶
| Reason code | Emitted by | Means |
|---|---|---|
CURSOR_GAP_DETECTED |
The control plane | The node's position is past the stream revision |
ASSIGNMENT_CURSOR_GAP_DETECTED |
The node | A resync is required and the control plane named no reason |
ASSIGNMENT_CURSOR_CORRUPTION_DETECTED |
The node | The cursor record failed its checks |
ASSIGNMENT_CURSOR_RESYNC_REQUIRED |
The node | The position must be restored from the control plane |
Related¶
- Resume direction for why the recovery always moves the position back.
- The assignment cursor for the record a resync rewrites.
- Recovering the DP to kernel link for the return lane's reconnect path.