fix(alarms): #958 a broadcast copy the local engine refuses reverts the node
When the direct verdict ask expired before the engine reached it, or never started before its asker's deadline, the host answered OutcomeUnknown and let the broadcast copy decide - but nobody awaited that copy, so a local refusal left the SDK-applied node change until the next good deploy. The host now keeps a pending decision per CommandId and returns it as the unknown answer's LateOutcome; OnAlarmCommand settles it with the copy's local outcome (applied / refused / unknown / not owned). The node manager's existing #951 chain follows it, so a refused copy reverts the node under the per-condition mutation-counter guard (one chain, one terminal verdict - no double revert; a newer change wins). Never-arriving copies settle unknown after 30 s; a stopping host settles its pending decisions unknown; at most 1024 pending per host. Tests: Runtime host tests (refused/applied copy settles the late outcome, copy-first answers directly, window expiry, stop) - red without the LateOutcome wiring; wire test of the production chain reverting exactly once, and not at all after a newer change (falsified by disabling the mutation guard). Docs: ScriptedAlarms.md residual + #958 section, rules/alarms.md.
This commit is contained in:
+20
-4
@@ -454,7 +454,7 @@ of which blocks under the node manager's `Lock`:
|
||||
| applied (incl. an idempotent no-op) | `Good` |
|
||||
| refused — last load failed, alarm not loaded on this node (incl. the window after a host supervision restart before its reload), malformed command, no engine on this node | `BadInvalidState` (node reverted; the peer never received it) |
|
||||
| no answer within min(5 s, request deadline − 250 ms), or the engine op timed out / failed in the store | `BadTimeout` / `BadInternalError`, diagnostic "OutcomeUnknown" — the command **may still apply**, never reported as refused (a refusal that arrives later still reverts the node, #951) |
|
||||
| the engine never started it — still waiting for the engine gate (e.g. behind a long load) when the host's 10 s op bound expired (#952) | `BadInvalidState` while the asker still waits (definite: nothing ran); once the asker has already answered OutcomeUnknown and broadcast it, the host answers unknown and lets the broadcast copy decide |
|
||||
| the engine never started it — still waiting for the engine gate (e.g. behind a long load) when the host's 10 s op bound expired (#952) | `BadInvalidState` while the asker still waits (definite: nothing ran); once the asker has already answered OutcomeUnknown and broadcast it, the host answers unknown and lets the broadcast copy decide (a refusal of that copy still reverts the node, #958) |
|
||||
|
||||
`BadInvalidState` is Part 4's general "object … uninitialized or in some other invalid state" code; Part 9's method result
|
||||
codes (bad EventId, already acked/confirmed/shelved, disabled, shelving time out of range) do not cover "the state owner
|
||||
@@ -492,6 +492,22 @@ unknown). The host maps not-started to `NotApplied` and remembers it, except on
|
||||
passed: that asker already answered OutcomeUnknown and broadcast the command, so — like an ask that expired before it started
|
||||
— the host answers unknown and does not remember it, and the broadcast copy decides locally too.
|
||||
|
||||
**A refused broadcast copy (#958).** Whenever the host answers a direct ask "the broadcast copy decides" — the ask expired
|
||||
in its mailbox before the engine reached it (review r2 M2), or the engine never started it before the asker's deadline
|
||||
(#952) — that unknown answer now carries the copy's outcome as its `LateOutcome`: the host keeps a pending decision per
|
||||
`CommandId` and completes it when `OnAlarmCommand` decides the broadcast copy of the same id (applied, refused, unknown, or
|
||||
not owned — e.g. a deploy removed the alarm). The node manager already follows a chain of unknowns (#951), so a copy the local
|
||||
engine REFUSES (typically: the deploy the command queued behind failed) reverts the node under the same per-condition
|
||||
mutation-counter guard — skipped when anything changed the node since the method (newer truth wins, including a newer
|
||||
operator method). There is one chain per method call and one terminal verdict, so the #951 late path and the copy cannot
|
||||
both revert; a repeat would be refused by the counter anyway (the revert's corrective event bumps it). A copy that reached the
|
||||
host BEFORE the expired ask is remembered and answers the ask directly. If the copy never arrives (the publish failed) the
|
||||
pending decision settles unknown after `ScriptedAlarmHostActor.DefaultBroadcastDecisionWindow` (30 s) and the node keeps the
|
||||
change; a host that stops settles its pending decisions unknown. At most 1024 decisions are pending per host (past that the
|
||||
answer carries none, as before). The pending outcome's continuations run off the host's thread — the revert takes the SDK
|
||||
`Lock`. As with #951, the redundant peer received the copy too and may have applied it; the revert makes this node match its
|
||||
own engine.
|
||||
|
||||
**Superseded load failure (#953).** A failed load pipes back with its load generation; a failure from a generation a newer
|
||||
apply has already superseded publishes nothing to the readiness view (the newer load is in flight and has typically cleared
|
||||
the engine's complete-generation flag, so reading it would refuse every command until that load completes — the view must
|
||||
@@ -499,9 +515,9 @@ let through while a load is pending; the engine queues a command behind it). The
|
||||
|
||||
**Residual.** Only the pre-check stops the SDK from applying the node change, so a refusal that arrives through the ask
|
||||
shows subscribers two events: the method's, then the corrective one. An OutcomeUnknown leaves the node changed (the engine
|
||||
may still apply it) unless a late refusal arrives inside the late window (#951). A command whose direct ask gave up and whose
|
||||
broadcast copy is then refused by the local engine (no one awaits a broadcast copy) still keeps the node change until the
|
||||
next good deploy re-asserts it. (#958) A command racing the engine's first load queues behind it rather than failing.
|
||||
may still apply it) unless a late refusal arrives inside the late window (#951) or the local engine refuses the broadcast copy
|
||||
that decides it (#958); a copy that never reaches the local engine within 30 s leaves the node changed until the next good
|
||||
deploy re-asserts it. A command racing the engine's first load queues behind it rather than failing.
|
||||
The AdminUI `/alerts` buttons report the engine's verdict too since #950 — see [AdminUI path](#adminui-path).
|
||||
|
||||
`OnTimedUnshelve` (the SDK's internal auto-unshelve timer, armed for the real remaining time since Gitea #597) is a **no-op**: the engine owns timed-shelve expiry via `ApplyShelvingCheck` (`system / AutoUnshelve`), and routing an `Unshelve` from the timer pre-empted that on every expiry as an operator-style unshelve from both pair nodes (review R1 M2).
|
||||
|
||||
Reference in New Issue
Block a user