fix(alarms): #937 review r2 — deadline/poison refusals unsent, Call size quota, expired asks skip the engine, mutation-counter revert guard
M1: a scripted method whose request deadline leaves < the dispatch floor, or that follows an unanswered scripted method in the same Call, is refused BadTimeout in its handler (unsent, unapplied); OpcUa:Quotas:MaxNodesPerMethodCall = 1000. M2: ExecuteAlarmCommand carries the asker's deadline; an expired ask skips the engine and is not remembered (the broadcast copy applies). L1: revert guarded by a per-condition mutation counter; raw severity restored. L5 + nits: docs, stale comment. SDK check: no Part 9 handler calls our delegate before its own validation. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -438,7 +438,14 @@ of which blocks under the node manager's `Lock`:
|
||||
revert. Cheap refusals the engine would make (a blank scripted AddComment ⇒ `BadInvalidArgument`) happen in the
|
||||
handler, before the SDK applies anything.
|
||||
3. **Load bound** — at most 64 asks outstanding node-wide (`MaxScriptedCommandsInFlight`); past it the call is refused
|
||||
`BadTooManyOperations` before anything is applied or sent. Each request's 5 s bound starts when its own ask is sent.
|
||||
`BadTooManyOperations` before anything is applied or sent. Each request's 5 s bound starts when its own ask is sent and
|
||||
is cut by the request deadline; a scripted method whose deadline leaves less than 250 ms (after a 250 ms grace) is
|
||||
refused `BadTimeout` unsent, and after the FIRST scripted method of a batch that got no answer every later scripted
|
||||
method of that batch is refused `BadTimeout` unsent (non-scripted methods in the batch still run) — so a wedged engine
|
||||
costs one bound per Call, not one per method. A Call carries at most `OpcUa:Quotas:MaxNodesPerMethodCall` methods
|
||||
(default 1000; the SDK default 0 was unlimited; 0 restores it). The host answers an ask still queued past its asker's
|
||||
deadline without touching the engine and without remembering it, so its broadcast copy (which the peer also received —
|
||||
the asker had reported OutcomeUnknown) is what applies; late work cannot pile up behind a stalled store.
|
||||
Measured through one host with the production LocalDb store (`ScriptedAlarmCommandThroughputTests`): 300 sequential
|
||||
acks in 59 ms (max 11 ms each); 300 AddComments with 64 outstanding at once in 49 ms (max 24 ms each).
|
||||
|
||||
@@ -459,6 +466,15 @@ broadcast, so no engine anywhere applied it and the revert plus the definite fai
|
||||
gRPC-data `CallConditionMethod` on a scripted condition carries the same verdict (`ExecuteConditionMethodAsync`): applied ⇒
|
||||
`DriverConfirmedSuccess`, refused after dispatch ⇒ `DriverConfirmedFailure`, no answer ⇒ `OutcomeUnknown`.
|
||||
|
||||
**Behaviour change (review r2 L5).** A scripted method is now REFUSED (`BadInvalidState`), reverted, and NOT broadcast to
|
||||
the redundant peer when this node has no scripted-alarm host (no condition-state store, or the host not yet spawned) or the
|
||||
host does not own the alarm — including the window after a host supervision restart before its configuration is re-sent.
|
||||
Before #937 such a call returned Good and the broadcast let the peer apply it.
|
||||
|
||||
**Revert guard.** A refusal reverts the node only when its per-condition mutation counter (bumped by every projection,
|
||||
every reported condition event and every accepted method) is unchanged since the method — a field comparison missed a
|
||||
Timed→Timed re-shelve or a ClientUserId change. The captured raw severity is restored as captured.
|
||||
|
||||
**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). A command racing the engine's first load queues behind it rather than failing.
|
||||
|
||||
@@ -87,3 +87,20 @@ origin `ack` ⇒ `Acknowledge successful` (positive control).
|
||||
| Host.Tests (incl. `GrpcDataV1CompatibilityTests`) | 503 passed |
|
||||
| Commons.Tests / Core.ScriptedAlarms.Tests | 513 / 147 passed |
|
||||
| Live `fu937-3` (`6004a5a56`) | F937 + A01 + A02 3/3 PASS; rig down |
|
||||
|
||||
## Review round 2
|
||||
|
||||
| # | Finding | Outcome | Red on revert |
|
||||
|---|---|---|---|
|
||||
| M1 | Each request floored at 50 ms ⇒ past the deadline every remaining request still applied/asked; TimeoutHint 0 × wedged engine ≈ 5 s per method | **Fixed.** Deadline (− 250 ms grace) leaving < the 250 ms dispatch floor ⇒ the scripted handler refuses `BadTimeout` unsent (the SDK applies nothing); after the first timed-out OutcomeUnknown in a batch the rest of its scripted methods are refused the same way (non-scripted still run). New quota `OpcUa:Quotas:MaxNodesPerMethodCall` = 1000 (SDK default 0 = unlimited; 0 restores it). | `A_too_close_deadline_or_an_earlier_unanswered_command_refuses_scripted_methods_unsent` red with the floor/poison removed; quota pinned in `OpcUaApplicationHostQuotaTests` |
|
||||
| M2 | Cap released on Ask timeout while the command stays queued in the host ⇒ unbounded late work | **Fixed.** `ExecuteAlarmCommand.DeadlineUtc`; an expired ask is answered without touching the engine and NOT remembered, so its broadcast copy (already sent on Unknown) applies. Answered OutcomeUnknown rather than NotApplied: the broadcast copy may still apply here, so "not applied" would be untrue (nobody is waiting for it anyway). | `An_expired_ask_skips_the_engine_and_leaves_the_broadcast_copy_to_apply` red with the check removed |
|
||||
| L1 | Revert guard compared delta + comment | **Fixed.** Per-instance mutation counter (`ConditionalWeakTable`), bumped in `ApplyConditionState`, `ReportConditionEvent` and on every accepted method in `ReportAfterMethod`. | `A_refusal_does_not_revert_a_node_changed_since_the_method` (identical re-projection) red with the guard removed |
|
||||
| L5 | Behaviour change undocumented | `docs/ScriptedAlarms.md`: no local host / not owned (incl. the post-supervision-restart window) ⇒ refused + reverted + no peer broadcast. | docs |
|
||||
| nits | stale hosted-service comment; severity 0 ⇒ 1 on revert | Fixed (comment says ask-then-broadcast; the raw captured severity is restored). | — |
|
||||
| SDK check | Does any Part 9 handler call our delegate before its own validation? | **No** (decompiled SDK 2.0.1): Acknowledge/Confirm/AddComment run the delegate at the END of `ProcessBefore*` (after EventId/Enabled/already-acked/IsLive); the three shelve methods after Enabled + `IsCausePermitted` (+ shelving-time range); Enable/Disable after the already-enabled checks. Nothing after a Good delegate can turn the call Bad, so a started ask is always awaited. (Branch acks would recurse into a branch's own delegate — this server creates no branches.) | — |
|
||||
|
||||
Follow-ups (not fixed): **L2** a late refusal that arrives after the ask's timeout (the caller got OutcomeUnknown) is never reverted; **L3** a command cancelled while waiting on `_evalGate` (nothing applied) is reported OutcomeUnknown, not NotApplied; **L4** `OnLoadFailed` reads `HasCompleteGeneration` while a newer load may already be running (transiently refuses during that load).
|
||||
|
||||
Gates (round 2): build 0 warnings / 0 errors; OpcUaServer.Tests 1460 passed / 2 skipped; OpcUaServer.IntegrationTests 441 / 39 skipped;
|
||||
Runtime.Tests 2122 / 3 skipped; Host.Tests 503; Commons.Tests 513; Core.ScriptedAlarms.Tests 147. No live re-run (the dispatch
|
||||
order is unchanged; the new refusals are pre-dispatch and the expiry skip is host-local).
|
||||
|
||||
Reference in New Issue
Block a user