fix(opcuaclient): #946 rate-limit RefreshRequired sweeps; #947 refused per-ack status throws DriverOperationRefusedException

#946: AlarmRefreshRequiredMinInterval (default 10 s, 0 disables) spaces RefreshRequired-triggered ConditionRefresh sweeps per session; a request inside the window is deferred to its end and coalesced, never dropped.
#947: AcknowledgeAsync throws the breaker-exempt DriverOperationRefusedException for Bad per-ack statuses and unresolvable condition ids (BadConditionBranchAlreadyAcked is success) so the #760 revert fires. Docs reverse the O-8 decision.
This commit is contained in:
Joseph Doherty
2026-12-01 19:24:01 -05:00
parent 6b60845931
commit 0ccfd88a23
5 changed files with 434 additions and 33 deletions
+23 -7
View File
@@ -289,10 +289,10 @@ The session keep-alive (`KeepAliveInterval`, default 5 s) is the liveness signal
no health — including a write the host cancelled at its own write deadline against a hung upstream; the session
keep-alive owns liveness and reports that outage itself. A reply that was in flight across a bad keep-alive advances
the stamp but does not write `Healthy` while the outage is published — the keep-alive recovery ends the outage.
An ack none of whose condition ids resolves sends nothing and logs a Warning — it does **not** throw (a deterministic
per-ack refusal must not count toward the host's AlarmAcknowledge circuit breaker, or five re-acks of one
unresolvable condition would block every genuine ack). Only a call with no reply throws; with no session an ack
fails `BadNotConnected` (before or inside the gate alike).
An ack none of whose condition ids resolves sends nothing, logs a Warning and **throws the breaker-exempt
`DriverOperationRefusedException`** (#947 — it used to return silently; see "A refused ack is refused" below). A call
with no reply throws a `ServiceResultException`; with no session an ack fails `BadNotConnected` (before or inside the
gate alike).
- **Bad keep-alive** ⇒ health `Degraded` (`LastError = "keep-alive: <status>"`, read stamp preserved), host status
`Stopped`, and — **once per outage**, not per keep-alive — every subscribed ref is published `BadNoCommunication`
with its last value retained and **source + server timestamp = the detection time** (live-gate F1: stamped with the
@@ -473,7 +473,11 @@ initialise (the AdminUI form drops them on the next save). Pinned by
> consumer), keeps them out of the backstop, and diagnoses them if no signal follows.
> - **Retry bounds:** at most 3 re-refreshes run per episode, backing off 2 s, 4 s and 8 s. A clean RefreshEnd resets
> the budget. Once the budget is spent, a further loss gets a new budget only after a 5-minute cool-down.
> - **RefreshRequired:** its sweeps are coalesced while one is queued. The alarm event item asks for a
> - **RefreshRequired:** its sweeps are coalesced while one is queued **and rate-limited (#946)**: at least
> `alarmRefreshRequiredMinInterval` (default 10 s, start to start; `00:00:00` disables) separates two sweeps on one
> session. A request inside the window is **deferred** to the window's end, never dropped, and everything arriving
> meanwhile coalesces into that one sweep; a new session starts a fresh window. Reconnect / re-subscribe / loss-retry
> refreshes (own 3-attempt budget) are not subject to it. The alarm event item asks for a
> queue of 10,000 (previously 1,000); the server may revise it down. Counters on `otopcua.driver.opcuaclient.events`:
> `alarm_event_queue_overflow` and `alarm_refresh_lossy`.
> Last-told state survives a re-initialise (the host re-subscribes the same set over nodes it did not rebuild) and is
@@ -484,8 +488,20 @@ initialise (the AdminUI form drops them on the next save). Pinned by
> **An ack that never got a reply fails (review 2026-10-21 O-8).** A transport failure on the `Acknowledge` call
> (closed channel, faulted session) — or a session lost while the ack queued — now throws with its status
> (`ServiceResultException`, e.g. `BadConnectionClosed` / `BadNotConnected`), so the host logs the ack as failed
> instead of applied. A *reply* still returns normally, including per-ack refusals such as
> `BadConditionBranchAlreadyAcked` (logged per ack): a refusal is the server answering.
> instead of applied.
>
> **A refused ack is refused (#947, reverses the O-8 decision).** A *reply* carrying a Bad per-ack status
> (`BadUserAccessDenied`, `BadNodeIdUnknown`, `BadEventIdUnknown`, `BadInvalidState`, …) — or a condition id that does
> not resolve against the live session — used to be logged and swallowed, so the host never saw a failure, the #760
> revert never fired, and the node kept showing an ack upstream had refused. It now throws
> `DriverOperationRefusedException` (one per call, naming each refused condition + status). That type is exempt from the
> resilience pipeline's retry **and** circuit breaker, which is the reason the earlier decision gave for *not* throwing
> (five refused re-acks opening the AlarmAcknowledge breaker); with it gone the reason is gone. The refusal is a reply,
> so it neither degrades health nor counts as a comms fault. Results are matched to the acks actually sent (an
> unresolvable id in a batch is refused after the resolvable ones are sent). **`BadConditionBranchAlreadyAcked` is
> success** (logged at Information): the condition is already in the requested end state, and reverting would un-ack
> a condition that IS acked. Part 9 defines no other already-acked status. This driver implements no Confirm / Shelve /
> Enable / Disable — `AcknowledgeAsync` is the only upstream condition method it calls, so there is no sibling path.
> This driver does **not** implement `IRediscoverable` — there is no
> push-driven rediscovery signal from a remote OPC UA server in this driver.