test(grpc-data): #928 — overflow test asserted one of two legal outcomes; deterministic Reset test + either-outcome contract test; DataConnections.md A4 reconcile (#930 retries, condition metrics, AdminUI fields)

The origin item sees a hub eviction only at its next hub read: Reset if the last snapshot chunk is
still undelivered, otherwise a silent fresh snapshot on the same stream (both per A2, both loss-free
since the A3 consumer swaps a buffered re-snapshot in as a full replacement). Since A2 review S5 the
3,000-record snapshot is 59 chunks and the silent path wins when run alone (fails 3/3 alone at the A2
merge too; passes in its class). No product change. Also fixes the stale ack/confirm/shelve comment on
ConditionMethodTimeoutMilliseconds.
This commit is contained in:
Joseph Doherty
2026-11-25 00:08:06 -05:00
parent 3be51e3b13
commit b2fab8b075
4 changed files with 204 additions and 32 deletions
+60 -16
View File
@@ -359,14 +359,17 @@ An origin streams its alarm condition state to a peer that negotiated `condition
arrive as delta records. The consumer reconnects and takes a complete snapshot of the new catalog. (Corrected in the A2
review, S1. Earlier text here said a deploy's adds/removes arrive as deltas; only a fixture could do that.)
- **Priority and overflow.** A control or ack at the head of the stream goes first, then condition frames, then queued
values. Condition production is pull-based: a slow consumer leaves records in the bounded condition-state hub; if the hub
evicts records the item has not read, the item takes a fresh snapshot, and if that happens while its previous snapshot
is still undelivered the stream is `Reset` ("Condition stream overflow; retry later.").
values. Condition production is pull-based: a slow consumer leaves records in the bounded condition-state hub. The item
notices an eviction of records it has not read the next time it reads the hub. If its previous snapshot's last chunk is
still undelivered at that moment, the stream is `Reset` ("Condition stream overflow; retry later."). Otherwise the item
takes a fresh snapshot on the same stream (a new snapshot begin, counted as a resync). Which of the two happens for an
eviction during a long snapshot delivery depends on scheduling. Both are correct and neither loses a change: the consumer
replaces its set with the next complete snapshot, either on a reconnect or by swapping the buffered re-snapshot at
`snapshot_complete` (#928).
- **Revocation** (grant, catalog or authority change) ends the stream like a revoked v1 value item; no further condition
frame is delivered.
- **Limits** (`AddDataConnectionConditions`): `DataExport.MaxConditions` (1000, ≤ 5000) and `RemoteNamespaceMapping.MaxConditions`.
The consumer-side timeouts are under "Limits and defaults" below. Metrics: `otopcua.dataconn.conditions.items`, `…resyncs`,
`…capacity_rejections`.
The consumer-side timeouts are under "Limits and defaults" below. Metrics: see "Diagnostics and troubleshooting".
## Condition forwarding end to end (A1–A3)
@@ -406,9 +409,25 @@ refresh, EventIds) is documented in [Alarm tracking § Imported conditions](Alar
`ConditionSnapshotTimeoutMilliseconds` has passed.
- A mapping that is incomplete at the barrier is `Unavailable`. The others proceed, and clients get `RefreshRequired`.
- A mapping that completes late is merged in.
- A mapping still `Unavailable` after the barrier ends the stream after a bounded wait
(`ConditionSnapshotTimeoutMilliseconds` × 1, 2, 4, 8 backoff).
- TODO(A4 #930 reconcile): describe the refused-mapping backoff and the in-stream `ConditionCapacity` recovery as merged.
- An `Unavailable` mapping (item refused, root metadata failed, snapshot timed out) or a `ConditionCapacity` mapping is
**retried on the open stream** (#930). Its root is re-resolved if it never resolved, any item it still holds is removed,
and a new item is added. The stream is not ended for it, so the healthy mappings are never re-snapshotted and their
methods are never answered `BadNoCommunication` because of it.
- Retry delay, per mapping. A **definitive** refusal (`Denied`, `NotFound` or `Unsupported`, for the item or the root
metadata) or `ConditionCapacity` waits `LongRetryDelay` (5 min) × 2ⁿ, capped at 4× (20 min). Any other refusal or a
snapshot timeout waits `ConditionSnapshotTimeoutMilliseconds` × 2ⁿ, capped at 8×. A retry whose snapshot has not
completed by its deadline goes back to `Unavailable` and releases its claim; a late completion is still taken. A
completed snapshot resets the count. While a retry runs the mapping is `Pending` (unknown), so nothing it might list is
removed or marked known-inactive (T2).
- `ConditionCapacity` therefore recovers in-stream: after the origin's listing shrinks (or the limit is raised) the next
retry's snapshot is admitted and swapped in.
- `RefreshRequired` is sent at an incomplete barrier only when its set of incomplete mappings differs from the previous
barrier's. A mapping that stays refused across stream restarts does not cause a refresh storm. A mapping that completes
leaves the set, so a later relapse is announced again.
- A stream that ends before its barrier (every root failing, no Primary) reconnects after `ReconnectDelay` (1 s) × 2ⁿ⁻¹,
capped at `MaxReconnectDelay` (60 s). The count resets when a barrier passes. Repeated ends log at Debug after the first.
`LongRetryDelay`, `ReconnectDelay` and `MaxReconnectDelay` are fixed `ProjectedConditionOptions` defaults, not host
configuration.
6. **Lifetime rule.** The end of a stream means "re-snapshot", never "removed".
- During a disconnect, imported conditions keep their last state. After `ConditionStaleTimeoutMilliseconds` their
`Quality` becomes `BadNoCommunication`: one event per condition, with Active/Acked unchanged.
@@ -544,11 +563,36 @@ when Σ `MaxConditions` × 49 of a consumer node's mappings exceeds `MaxImported
### Diagnostics and troubleshooting
TODO(A4 diagnostics reconcile): list the condition metrics (consumer stream state, snapshot time, condition count vs limit
with the 80 % warning, capacity state, `state_known = false` count, RefreshRequired count, method outcomes) and the
**Data connections** page fields here, with their exact names, once the A4 diagnostics branch merges. Today's metrics:
`otopcua.dataconn.conditions.items`, `…resyncs`, `…capacity_rejections`, `…unsignalled`, `…partition_overflows`,
`…marks_discarded` and `otopcua.dataconn.condition_methods` (tags `method`, `outcome`; origin).
Metrics, on the `ZB.MOM.WW.OtOpcUa` meter, never carry a connection, node, mapping or principal id in a label. The shared
ones carry `side` = origin | consumer, because a node can be both:
| Instrument | Type | Labels | Meaning |
|---|---|---|---|
| `otopcua.dataconn.conditions.items` | up/down counter `{item}` | `side` | Origin: root-scoped condition items open for peers. Consumer: the items its condition streams hold open (one per acked mapping item). |
| `otopcua.dataconn.conditions.resyncs` | counter `{resync}` | `side` | Origin: an item re-snapshotted after a hub reader reset. Consumer: a condition stream that ended (the next one re-snapshots). |
| `otopcua.dataconn.conditions.capacity_rejections` | counter `{item}` | `side` | Origin: an item snapshot over its `MaxConditions` (or refused by the snapshot memory budget). Consumer: a mapping reset to `ConditionCapacity` (over its `MaxConditions` or the host caps). |
| `otopcua.dataconn.condition_methods` | counter `{call}` | `method`, `outcome` (the `DataWriteState`), `side` | Origin: calls served. Consumer: calls forwarded (a call the local node manager refuses before forwarding is not counted). |
| `otopcua.dataconn.conditions.refresh_required` | counter `{request}` | `side` = consumer | RefreshRequired requests the consumer runtime made: an incomplete barrier with a changed incomplete set, a capacity reset that removed nothing, each removal batch. Not per client item. |
| `otopcua.dataconn.conditions.unsignalled` | counter `{condition}` | — | Origin: native conditions whose initial state was not signalled within the signal timeout. |
| `otopcua.dataconn.conditions.partition_overflows` | counter `{overflow}` | — | Origin: condition-state hub partition overflows. |
| `otopcua.dataconn.conditions.marks_discarded` | counter `{mark}` | — | Origin: deferred condition-known marks discarded after their alarm projection was dropped. |
The AdminUI **Data connections** page (`/clusters/{id}/data-connections`) shows, per connection on a consumer node, an
"Imported conditions" line. It reads "no condition-bearing mapping (or evidence unavailable)" when there is none, or when the
node is older than A4. Otherwise it shows:
- `stream` state (idle, connecting, snapshotting or live) and `last snapshot` (UTC, or "none since start");
- `conditions` materialised, with the `state unknown` count (`state_known = false`);
- `node budget` charged against the host condition limit;
- `RefreshRequired`, `resyncs` and `capacity rejections` counts;
- `methods`, as succeeded / rejected / failed / unknown. Succeeded is DriverConfirmedSuccess, rejected is
RejectedBeforeDispatch, failed is DriverConfirmedFailure, and unknown is AcceptedUnconfirmed or OutcomeUnknown;
- `mappings`, one entry per mapping: id, status, observed count against its `MaxConditions`, and the refusal when refused.
The line takes the notice style when a mapping is `Unavailable` or `ConditionCapacity`, or when a mapping's count or the node
budget reaches 80 % of its limit ("≥ 80% of MaxConditions" / "≥ 80% of the host caps"). Each node's origin panel adds a
served-conditions segment: `condition items open`, `largest listing` against its limit (with the same 80 % note), `last
snapshot`, `resyncs`, `capacity rejections`, `state unknown (unsignalled)` and `methods served`.
Consumer logs (Information unless noted) record each condition stream it opens, each item the origin refuses (Warning, with
status and diagnostic), and each snapshot barrier (per-mapping status, record count, whether it timed out).
@@ -564,9 +608,9 @@ status and diagnostic), and each snapshot barrier (per-mapping status, record co
| Ack answers "OutcomeUnknown" | Check the origin's audit log (`ZB.MOM.WW.OtOpcUa.DataConnections.Audit`) for the operation and watch the condition's events. Never replay blindly. |
| All `ConditionId`s changed | `ConditionKeySecret` was rotated or differs between the origin pair members, or the connection was re-created under a new id. |
Open follow-ups: #927 (live-gate the driver-failure ack revert), #928 (an overflow test fails under load), #929 (re-measure
the per-condition memory figures in the plan), #930 (a refused mapping causes a refresh storm; `ConditionCapacity` never
recovers in-stream; A4 work in progress) and #931 (review nits).
Open follow-ups: #927 (live-gate the driver-failure ack revert) and #929 (re-measure the per-condition memory figures in
the plan). #928 (overflow test timing), #930 (refresh storm, in-stream `ConditionCapacity` recovery) and #931 (review nits)
are addressed in A4.
## Feature boundary