docs(grpc-data): A4 code evidence — #930/#931 red/green, diagnostics, live a4c-cond-1 PASS, L1 PASS, L5 docker-dev PASS (production blocked), gates
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
# A4 evidence — code part (diagnostics, #930, #931, L1, L5)
|
||||
|
||||
Phase A4 of `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md`, 2026-11-24/25, branch `a4-code` (from master
|
||||
`91438049`). Not merged, not pushed. The docs part (`DataConnections.md`, `AlarmTracking.md`, `ScriptedAlarms.md`, `security.md`)
|
||||
is a separate worktree; the A01–A08 fleet scenarios are not part of this code pass.
|
||||
|
||||
## #930 — a permanently refused mapping no longer storms (N2), ConditionCapacity recovers (N3)
|
||||
|
||||
`ProjectedConditionAccess.Runner.cs`:
|
||||
|
||||
- **In-stream retry.** A mapping that is Unavailable (item refused, root metadata failed, snapshot timed out) or ConditionCapacity is
|
||||
retried ON THE OPEN STREAM: its root is re-resolved if it never resolved, any still-open item is removed, and its item is re-added
|
||||
(`AddSubscriptionItems`, a fresh command id; acks are matched on `(mapping, command id)`). The stream is no longer ended for it, so
|
||||
the healthy mappings are never re-snapshotted and methods are not answered `BadNoCommunication` in a reconnect gap.
|
||||
- **Backoff per mapping.** Definitive refusals (`Denied`, `NotFound`, `Unsupported`, item or root) and ConditionCapacity:
|
||||
`ProjectedConditionOptions.LongRetryDelay` (new, default **5 min**) × 2ⁿ, ≤ 4×. Transient: the snapshot timeout × 2ⁿ, ≤ 8× (the old
|
||||
B2 schedule). A retry whose snapshot has not completed by its deadline goes back to Unavailable (claim released); a late completion
|
||||
of that item is still taken. A completed snapshot resets the retry count.
|
||||
- **RefreshRequired only on a changed incomplete set.** Each barrier records the set of mappings not known; an incomplete barrier
|
||||
whose set equals the previous barrier's (e.g. a stream that ended for another reason with the same mapping still refused) sends no
|
||||
RefreshRequired. A mapping that completes in-stream leaves the recorded set, so a later relapse is told again.
|
||||
- **T2 holds:** a retried mapping is `Pending` (unknown) while its retry runs, so nothing it might list is removed or marked
|
||||
known-inactive meanwhile; a capacity mapping's retry likewise blocks removals until it is known again.
|
||||
|
||||
Decision: a ConditionCapacity mapping is "known-empty" while parked but "unknown" during its retry window. Conservative (removals by
|
||||
other mappings in that window are held as `BadNoCommunication` instead of removed) — never the T2-unsafe direction.
|
||||
|
||||
## #931 — nits N4–N8
|
||||
|
||||
| Nit | Fix |
|
||||
|---|---|
|
||||
| N4 | A stream that ended before its barrier (every root failing, no Primary) backs off `ReconnectDelay × 2^(n−1)` up to the new `MaxReconnectDelay` (60 s); reset when a barrier passes. The repeated end logs at Debug after the first. |
|
||||
| N5 | The ledger charges `max(Materialised, Σ known claims + max(Unlisted, Σ unknown claims))`: held-but-unlisted keys (an Unavailable mapping's stale keys) are charged beside a **known** mapping's new claim (the under-count), but overlap an **unknown** mapping's claim (it may be re-listing those very keys — no false capacity rejection of a retry). The swap commits its count via `Commit` (never refused). `SetMaterialised` now reports when the node is over a cap (logged; materialising is never refused — bounded by Σ MaxConditions). |
|
||||
| N6 | `_runners` is a `ConcurrentDictionary` (mutated under `_gate` only); `CallAsync` and the diagnostics poll read a runner's `Serving` without `_gate`. No test (a lock-ordering change with no observable seam; reviewed by reading). |
|
||||
| N7 | A capacity reset whose reconcile removed conditions sends no second RefreshRequired — the removal already carried one to every item that held them (the sink's §5.2 "removal + RefreshRequired"); it still asks when nothing was removed. |
|
||||
| N8 | A parked (`_stopping`) runner is dropped once its removal finished (it hands over an empty set); new test observation `IsParked`. |
|
||||
|
||||
### Red/green (each reverted alone, the named test re-run, then restored)
|
||||
|
||||
| Fix | Revert | Test | Red |
|
||||
|---|---|---|---|
|
||||
| N2 in-stream | end the stream when a retry is due | `B2_S7_a_refused_item…` (rewritten: Add arrives, no new stream, map-b not re-applied) and `N3_a_ConditionCapacity_mapping_is_re_added_in_stream…` | both red |
|
||||
| N2 unchanged set | `alreadyTold = false` | `N2_an_unchanged_incomplete_set_on_a_new_stream…` | red |
|
||||
| N2 definitive | `Definitive` ignores the refusal status | `N2_a_definitive_refusal_waits_the_long_backoff…` | red |
|
||||
| N4 | fixed `ReconnectDelay` | `N4_streams_that_never_reach_a_barrier_back_off_exponentially` (< 12 metadata calls in 2 s; ~40 without) | red |
|
||||
| N5 | `known + unknown` (old under-count) | `N5_held_stale_keys_are_charged_beside_a_known_mappings_new_claim…` | red |
|
||||
| N7 | `if (outcome.Refresh) RequireRefresh()` | `B1_an_in_stream_re_snapshot_over_capacity…` (now asserts one RefreshRequired per reset: the removal's) | red |
|
||||
| N8 | continuation never removes the parked entry | `N8_a_stopped_runner_is_not_kept_parked…` | red |
|
||||
|
||||
Also new: `N3_a_retry_still_over_capacity_stays_ConditionCapacity…` (backoff doubles, map-b's key never removed).
|
||||
|
||||
Test-only fix found on the way: the condition-access tests waited for `BarriersCompleted` and then asserted RefreshRequired, but the
|
||||
barrier count moves before the barrier's refresh (the A4 manifest's first run caught it in `N2_an_unchanged…`); they now wait for
|
||||
the refresh itself, with the third stream's refresh as the positive control for the second stream's absence.
|
||||
|
||||
## Diagnostics and metrics (plan §6)
|
||||
|
||||
- **`Runtime/DataConnections/DataConnectionConditionDiagnostics.cs`** (new DI singleton, no dependencies — the H4 shape): shared by
|
||||
the origin condition items (`ConditionItemStream`, via `LocalDataServices.ConditionDiagnostics`), the consumer runtime
|
||||
(`ProjectedConditionAccess.Diagnostics`) and the readers (`DataConnectionDeploymentRuntime.ConditionDiagnostics`, `DriverHostActor`).
|
||||
The condition hub's unsignalled count is attached at DI time (no lazy-composition gap like H4 review 2).
|
||||
- **Metrics** (OtOpcUa meter, every one with `side` = origin | consumer, no ids): `otopcua.dataconn.conditions.items{side}`
|
||||
(consumer side new: one per acked mapping item), `…conditions.resyncs{side}`, `…conditions.capacity_rejections{side}`,
|
||||
`…condition_methods{method,outcome,side}` (consumer side new: every forwarded call), and the new
|
||||
`otopcua.dataconn.conditions.refresh_required{side=consumer}`. The A2 instruments were **reused** (only `side` added).
|
||||
- **Contracts** (Commons, additive optional members; older senders ⇒ null = "unavailable"): `DataConnectionDiagnosticsSnapshot.Conditions`
|
||||
(`ConsumerConditionDiagnostics`: stream state idle|connecting|snapshotting|live, last snapshot, materialised, `state_known=false`
|
||||
count, RefreshRequired, resyncs, capacity rejections, per mapping status / observed / MaxConditions / refusal, node budget vs host
|
||||
cap, method outcome classes), `NodeDiagnosticsSnapshot.OriginConditions` (`OriginConditionDiagnostics`: open items, the item
|
||||
nearest its limit, last snapshot, resyncs, capacity rejections, unsignalled, methods served). Arrays in production (H4 Akka JSON
|
||||
note); no bool flag was added.
|
||||
- **AdminUI** `ClusterDataConnections.razor` (already in `<PageErrorBoundary>`) + `DataConnectionDiagnostics` helpers: an
|
||||
"Imported conditions" line per connection (notice style when a mapping is Unavailable/ConditionCapacity or any count ≥ 80 % of its
|
||||
limit) and a served-conditions segment in the origin panel.
|
||||
|
||||
Decisions: the consumer RefreshRequired count is requests made by the runtime (explicit + each removal batch), not per client item;
|
||||
method outcome classes: DriverConfirmedSuccess = succeeded, RejectedBeforeDispatch = rejected, DriverConfirmedFailure = failed, the
|
||||
rest (AcceptedUnconfirmed, OutcomeUnknown) = unknown. A method the node manager refuses before forwarding (no local grant) is not
|
||||
counted on the consumer side.
|
||||
|
||||
Tests: Runtime `GrpcDataConditionDiagnosticsTests` (3), `GrpcDataConditionDiagnosticsSerializationTests` (2: cluster-serializer
|
||||
round trip; an older payload decodes `Conditions`/`OriginConditions` null), `GrpcDataProjectedConditionAccessTests.A4_consumer_diagnostics…`;
|
||||
AdminUI `GrpcDataConditionDiagnosticsDisplayTests` (4). Manifest key `A4` in `unit-phases.json`.
|
||||
|
||||
## AdminUI live — run `a4c-cond-1` (prerendered HTML from control-1's admin, login disabled)
|
||||
|
||||
`/clusters/CONSUMER/data-connections` after the smoke:
|
||||
- consumer-1: "Imported conditions: stream live · last snapshot 2026-11-25 04:44:51Z · conditions 1 (state unknown 0) · node budget
|
||||
1/2500 · RefreshRequired 0 · resyncs 0 · capacity rejections 0 · methods succeeded 1 · … · mappings map-raw Complete 0/1000;
|
||||
map-uns Complete 1/1000".
|
||||
- consumer-2 (no event subscriber): "stream idle · … · mappings map-raw Pending 0/1000; map-uns Pending 0/1000".
|
||||
- origin panel for consumer-1/2: "condition items open 0 · last snapshot none since start · … · state unknown (unsignalled) 0".
|
||||
|
||||
`/clusters/SOURCE/data-connections` origin panel: source-1 "condition items open 2 · largest listing 1/1000 · last snapshot
|
||||
2026-11-25 04:44:51Z · resyncs 0 · capacity rejections 0 · state unknown (unsignalled) 0 · methods served succeeded 1"; source-2
|
||||
(Secondary) zeros. `/metrics`: consumer-1 `conditions_items{side="consumer"} 2`, `condition_methods_total{method="Acknowledge",
|
||||
outcome="DriverConfirmedSuccess",side="consumer"} 1`; source-1 `conditions_items{side="origin"} 2`, the same method series with
|
||||
`side="origin"` 1 — page and metrics agree. Not driven in a browser (Chrome tools not used); prerender runs the same render.
|
||||
|
||||
## L1 — origin `SnapshotConditions` Lock hold (§9.3) — PASS (A1 had not measured it)
|
||||
|
||||
`A1-core.md`/`A1-L4.md` record only L4 (X0 measured a field copy outside the server). Measured now with the opt-in harness
|
||||
`OpcUaServer.Tests/ConditionSnapshotLockHoldMeasurementTests` (`OTOPCUA_L1=1`): a running SDK server, 1,000 native conditions +
|
||||
500 variables, two publisher threads (`WriteValue`, `WriteAlarmCondition`, both under `Lock`), 500 snapshots after 20 warm-up. The
|
||||
hold is an upper bound (keys-enumerated hook → post-hold hook; 1,000 = one hold at `DefaultMaxConditionsPerHold`). macOS (developer Mac),
|
||||
Debug build:
|
||||
|
||||
| Run | hold p50 / p99 / max (ms) | WriteValue p99 / max (ms) | WriteAlarmCondition p99 / max (ms) |
|
||||
|---|---|---|---|
|
||||
| 1 | 1.61 / 4.65 / 5.89 | 1.93 / 6.39 | 1.94 / 6.42 |
|
||||
| 2 | 1.44 / 4.32 / 5.00 | 1.71 / 6.34 | 1.71 / 6.38 |
|
||||
| 3 | 1.45 / 4.53 / 5.90 | 1.65 / 6.81 | 1.66 / 6.76 |
|
||||
|
||||
p99 ≤ 10 ms and no publish delayed > 50 ms: **pass**. In-process, not on docker-dev (deviation: the brief allowed in-process).
|
||||
|
||||
## L5 — condition counts vs defaults
|
||||
|
||||
- **docker-dev export** (run `a4c-cond-1`, from the new diagnostics): map-raw 0/1000, map-uns 1/1000 (0.1 %); consumer node
|
||||
1/2500 conditions (host caps 122,500 nodes / 400 MiB ⇒ 2,500); origin largest listing 1/1000. All ≤ 80 %: **pass**, defaults unchanged.
|
||||
- **Production export: BLOCKED.** No production ConfigDb is reachable read-only from configuration in the repo (production
|
||||
ConfigDbs are on the wonder boxes, which this brief forbids touching), and the data-connections feature is not deployed in
|
||||
production (v1 merged, undeployed), so no production export exists to count yet. To be filed.
|
||||
|
||||
## Gates (at `a4-code` HEAD)
|
||||
|
||||
| Gate | Result |
|
||||
|---|---|
|
||||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||||
| `run-unit-phase.py A4` (new) | passed (`20261125T040920…`) |
|
||||
| `run-unit-phase.py A3` / `A1` / `H4` / `X0` | passed |
|
||||
| `run-unit-phase.py A2` | first run failed `Overflow_before_the_snapshot_is_drained_resets_the_stream` (below); re-run passed (`20261125T042208…`) |
|
||||
| Host.Tests `.DataConnections.` | 207 passed |
|
||||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2066 passed, 3 skipped, 2 failed: `GrpcDataConfiguredDiscoveryWireTests` (#920) and `Overflow_before_…` (below) |
|
||||
| OpcUaServer.Tests full | 1458 passed, 2 skipped (the L1 harness is one) |
|
||||
| AdminUI.Tests full | 2707 passed |
|
||||
| OI combined (139) | 138 passed, 1 skipped |
|
||||
| Live `conditions_a3_smoke.py`, run `a4c-cond-1` | `passed: true` (imported ScalarHigh `ns=6;s=c1.…`, 32-char EventId; bogus EventId ⇒ BadEventIdUnknown; ack via consumer 635 ms; exactly one Active/Acknowledged on origin and consumer); `rig.py down` ⇒ 0 run containers / networks |
|
||||
| `git diff master -- '*Goldens.cs'` | empty |
|
||||
| Configuration.Tests | not touched |
|
||||
|
||||
### `GrpcDataConditionStreamTests.Overflow_before_the_snapshot_is_drained_resets_the_stream` — pre-existing, not caused by A4
|
||||
|
||||
Reproduced on a clean detached worktree of master `91438049`: **fails 2/2 when run alone** (`No DataSubscriptionControl.` after the
|
||||
10 s read timeout); in this branch also 4/4 alone, and with master's `ConditionItemStream.cs` + `DataSubscriptionSession.Conditions.cs`
|
||||
swapped in 2/2 alone. It passed in the A4 manifest run and the A2 re-run, failed in the first A2 run and the full Runtime suite here, and A3 recorded one full-suite failure.
|
||||
So it is an A2 test-timing defect, not an A4 regression, and not called a flake. Likely mechanism (from the code, not yet proven by
|
||||
instrumentation): the item raises a Reset **control** only when its hub read finds the eviction while the last snapshot chunk is
|
||||
still undelivered (`_deliveredSnapshot < Snapshots` ⇒ `Overflowed`); if that chunk's delivery is recorded before the item's next
|
||||
read, the item silently re-snapshots (`ResetSnapshot`) and no control is sent — which the test then waits for in vain. To be filed
|
||||
with that hypothesis.
|
||||
|
||||
## Left over
|
||||
|
||||
- File: production L5 count (blocked, above); the `Overflow_before_…` test-timing defect (above).
|
||||
- Not done here: A01–A08, reviewer approval, the ScadaBridge consumer-impact record, docs (other worktree).
|
||||
Reference in New Issue
Block a user