docs(grpc-data): #920 evidence — root causes, red/green, 30/30 class runs

This commit is contained in:
Joseph Doherty
2026-11-28 11:27:54 -05:00
parent 4cf06261f1
commit a105363832
+77
View File
@@ -0,0 +1,77 @@
# #920 — `GrpcDataConfiguredDiscoveryWireTests` flake: root causes
2026-11-28. Two unrelated causes, one in production and one in a test. Neither is a timeout, and nothing was widened or
skipped.
## 1. `Failed_sdk_item_construction_releases_candidate_and_fanout_ownership` — production race (fixed)
**Symptom.** The node manager's shared `ProjectedCandidateBudget` held 1 entry, expected 0.
**Cause.** Trace instrumentation (temporary, removed) showed that the extra entry was not the failed item's. It was a
proof candidate on the *existing* item 1, for the acquisition it had already delivered (`v=1 complete=True`, same proof).
The sequence:
1. Item 2's `CreateMonitoredItems` acquires a demand. Its stream registration gets the fake origin's snapshot, which
repeats item 1's acquisition (same version, still fresh).
2. The test's injected proof throws, so construction fails. The catch disposes the demand on the SDK thread.
3. That disposal raced the stream pump's `Publish` for the registration. The pump had passed the top check
(`!registration.Demand.IsValid`). The duplicate-baseline check `HasFreshCachedLocked(registration.Demand)` then read the
dying demand's `IsValid == false` as "the cache is not fresh". The trace shows `Publish v=1 complete=True last=1
fresh=False`.
4. So the same acquisition was published again as a new complete baseline to every item on the node. Item 1 kept a
candidate that no SDK notification will ever consume, because the node's value did not change. The candidate also
kept its shared budget charge.
In production this applies to any subscription whose demand is disposed while its snapshot is being published: a failed
item construction, a client deleting an item, or a session closing. Each such event re-baselines every other item on
the node and leaves one orphan candidate on each, until that item's binding changes.
**Fix** (`ProjectedDataAccess`):
- `HasFreshCachedLocked` no longer depends on the demand's validity. Whether the cached acquisition is fresh does not
depend on it.
- After the duplicate check, `Publish` re-checks the demand. A demand disposed since the top check publishes nothing
(`PublishDemand`).
- `AfterPublishDemandCheckForTests` is an internal seam on the pump.
**Regression test.** `A_demand_disposed_mid_publish_does_not_republish_a_fresh_baseline`:
- It disposes the second item's demand at the seam.
- Its positive control is a third item whose snapshot carries a new acquisition (v2) through the same in-order publisher.
- It asserts that no v1 baseline arrived before v2, and that item 1 holds exactly one candidate.
- **Red** with the two production lines reverted: `seen.Count(x => x.SourceVersion == 1) should be 0 but was 1`.
- **Green** with the fix.
## 2. `Bad_null_sdk_notification_cannot_borrow_unproven_sample_evidence("different_timestamp")` — test race (fixed)
**Symptom.** `BadNoCommunication` was delivered where `BadUserAccessDenied` was expected.
**Cause.** SDK 2.0.1 delivers a node change to its items asynchronously, from `MonitoredNode2.ProcessChannelAsync`. A
`QueueValue` stack trace confirmed this. Under load, the change for the sample the test had just published reached the
item *after* the test's `Disabled → Reporting` cycle and after its injected notification. At queue size 1 it overwrote
the injected notification (source timestamp T+1). The proven sample (T) that took its place correctly matched its
candidate and was correctly delivered.
So the production fence held, and the test's assumption that delivery is synchronous was wrong. The `different_status`
case already tolerates this ordering.
**Fix.** Before the mode cycle, the test waits until the SDK has queued the published sample. It checks the item's
`m_lastValue` for source timestamp T and `BadNoCommunication`, with a 10 s bounded wait that fails with a message.
The other scenarios were already robust:
- `ambiguous` and `missing_timestamp`: a late second sample is ambiguous against both candidates, so it is denied anyway.
- `expired_proof`: the proof is invalid, so the notification is denied anyway.
## Numbers (macOS, Release, shared host, load average 25–100 from parallel agents)
| | Before | After |
|---|---|---|
| Class runs (`--filter FullyQualifiedName~GrpcDataConfiguredDiscoveryWireTests`) | **5 / 16 failed** (4 × failed-construction, 1 × different_timestamp) | **30 / 30 consecutive passed** (111 tests each, incl. the new one) |
| `different_timestamp` stressed in-process (100 ×) | 16 / 100, 6 / 40 | 0 / 100 |
| failed-construction stressed in-process | 2 / 150 | 0 / 100 |
| New regression test (25 ×) | red, deterministic | 0 / 25 |
Other gates at `4cf06261`: `dotnet build ZB.MOM.WW.OtOpcUa.slnx -c Release` 0 warnings / 0 errors; Runtime.Tests (rest of the
suite, `Category!=E2E&Category!=LiveIntegration`) 1982 passed, 3 skipped; Host.Tests `.DataConnections.` (incl. the v1
compatibility gate) 207 passed.