Runtime.Tests: A_definition_replaced_by_a_renewal_never_resolves_as_missing fails ~8% under heavy load (TryResolve gives up after 16 back-to-back replacements) #970

Closed
opened 2026-12-02 15:17:14 -05:00 by dohertj2 · 1 comment
Owner

Found while stress-testing #969. Present on master 708a4889c, not caused by #969.

GrpcDataConfiguredDiscoveryWireTests.A_definition_replaced_by_a_renewal_never_resolves_as_missing (#968's regression test) fails about 8% of runs under heavy parallel load: 22 of 280 runs, with 14 parallel dotnet test lanes and 14 CPU burners on 14 cores. The rate is the same on master binaries and on the #969 branch. It always fails on the same assertion: a live node resolved as missing N times in ~1M lookups racing ~150k renewals, with N between 1 and 12.

Likely cause: OtOpcUaNodeManager.TryResolve / TryResolveForRenewal re-evaluate a replaced definition at most MaxProjectedResolveAttempts = 16 times. The test's renewer swaps the definition in a tight loop (~100k swaps/s), so a reader that is preempted mid-check can see 16 consecutive replacements and give up, reporting the node missing. Production renewals are seconds apart, so the product impact is theoretical. The test, however, asserts an absolute zero.

Options:

  • (a) Fall back to a locked read (or an unbounded loop that cannot livelock) after the bound is exhausted, so the guarantee is absolute.
  • (b) Pace the synthetic renewer to a realistic rate, or assert a bound instead of zero.

Option (a) is preferable if the locked read cannot deadlock with the demand-check callers that the lock-free path exists to protect (they can hold a source gate that SDK publication also needs). That constraint probably makes (b) the safe choice.

Repro: build Runtime.Tests, copy bin/Debug/net10.0 aside, run dotnet test <dll> --filter FullyQualifiedName~A_definition_replaced in 14 parallel loops next to 14 busy loops.

Found while stress-testing #969. Present on master `708a4889c`, not caused by #969. `GrpcDataConfiguredDiscoveryWireTests.A_definition_replaced_by_a_renewal_never_resolves_as_missing` (#968's regression test) fails about 8% of runs under heavy parallel load: 22 of 280 runs, with 14 parallel `dotnet test` lanes and 14 CPU burners on 14 cores. The rate is the same on master binaries and on the #969 branch. It always fails on the same assertion: `a live node resolved as missing N times in ~1M lookups racing ~150k renewals`, with N between 1 and 12. Likely cause: `OtOpcUaNodeManager.TryResolve` / `TryResolveForRenewal` re-evaluate a replaced definition at most `MaxProjectedResolveAttempts = 16` times. The test's renewer swaps the definition in a tight loop (~100k swaps/s), so a reader that is preempted mid-check can see 16 consecutive replacements and give up, reporting the node missing. Production renewals are seconds apart, so the product impact is theoretical. The test, however, asserts an absolute zero. Options: - (a) Fall back to a locked read (or an unbounded loop that cannot livelock) after the bound is exhausted, so the guarantee is absolute. - (b) Pace the synthetic renewer to a realistic rate, or assert a bound instead of zero. Option (a) is preferable if the locked read cannot deadlock with the demand-check callers that the lock-free path exists to protect (they can hold a source gate that SDK publication also needs). That constraint probably makes (b) the safe choice. Repro: build Runtime.Tests, copy `bin/Debug/net10.0` aside, run `dotnet test <dll> --filter FullyQualifiedName~A_definition_replaced` in 14 parallel loops next to 14 busy loops.
dohertj2 added the type:testpriority:p3 labels 2026-12-02 15:17:14 -05:00
Author
Owner

Fixed in e4740df2c (merged 440b182f3). The resolve now loops until it gets a stable read, with no 16-retry cap. Each retry needs a completed replacement of this exact node, and commits are serialized, so the loop terminates. A removed node or disposing server still exits immediately. A new deterministic test (64 back-to-back replacements) fails on old master and passes now. Stress: 22/280 -> 0/280.

Fixed in e4740df2c (merged 440b182f3). The resolve now loops until it gets a stable read, with no 16-retry cap. Each retry needs a completed replacement of this exact node, and commits are serialized, so the loop terminates. A removed node or disposing server still exits immediately. A new deterministic test (64 back-to-back replacements) fails on old master and passes now. Stress: 22/280 -> 0/280.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#970