fix(grpc-data): #968 a projected node replaced by a metadata renewal mid-lookup no longer resolves as missing
OtOpcUaNodeManager.TryResolve/TryResolveForRenewal read the committed definition map twice and answered false when a renewal replaced the definition between the reads. Every subscription demand check racing a renewal could then see its live node as gone and tear its physical stream down (freshness check breaking the attempt, 'Source unavailable' on the rebind baseline). Two cadences of one node made it likely: both renew on the same tick and the second, redundant renewal replaces the definition again while the first cadence rebinds - the residual ~1% hang of Two_sdk_cadences_renew_before_expiry (the barrier timeout was a victim). A lookup now re-evaluates a definition replaced mid-check (bounded). Regression: A_definition_replaced_by_a_renewal_never_resolves_as_missing (red: ~19% of lookups racing renewals answered missing), plus a wire test for two cadences committing the same successor.
This commit is contained in:
@@ -4428,12 +4428,16 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
{
|
||||
// Runtime demand checks can hold a source gate that SDK publication also needs.
|
||||
// Resolve committed metadata without acquiring the SDK address-space lock.
|
||||
var committed = Volatile.Read(ref _committedProjectedDefinitions);
|
||||
if (!_disposing && committed.TryGetValue(nodeId, out var current) && current.Lifetime.IsActive &&
|
||||
current.AuthorityIsCurrent() && !_disposing && current.Lifetime.IsActive &&
|
||||
Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var latest) &&
|
||||
ReferenceEquals(current, latest))
|
||||
// #968: the definition is re-read after its checks so a stale one is never answered. A renewal that REPLACED it in
|
||||
// between is not a missing node: evaluate the replacement. Answering false there made every subscription demand
|
||||
// check racing a metadata renewal see a live node as gone and tear its physical stream down.
|
||||
for (var attempt = 0; attempt < MaxProjectedResolveAttempts; attempt++)
|
||||
{
|
||||
if (_disposing || !Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var current)) break;
|
||||
var usable = current.Lifetime.IsActive && current.AuthorityIsCurrent() && !_disposing && current.Lifetime.IsActive;
|
||||
if (!Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var latest)) break;
|
||||
if (!ReferenceEquals(current, latest)) continue;
|
||||
if (!usable) break;
|
||||
definition = current;
|
||||
return true;
|
||||
}
|
||||
@@ -4441,16 +4445,22 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>#968: replacements a lock-free projected lookup re-evaluates before giving up (renewals are seconds apart).</summary>
|
||||
private const int MaxProjectedResolveAttempts = 16;
|
||||
|
||||
/// <summary>
|
||||
/// #922: like <see cref="TryResolve"/> but WITHOUT the authority check, so a node whose metadata lease lapsed can be renewed
|
||||
/// in place. Lock-free (committed snapshot), confers nothing.
|
||||
/// </summary>
|
||||
public bool TryResolveForRenewal(NodeId nodeId, out ProjectedVariableDefinition? definition)
|
||||
{
|
||||
var committed = Volatile.Read(ref _committedProjectedDefinitions);
|
||||
if (!_disposing && committed.TryGetValue(nodeId, out var current) && current.Lifetime.IsActive &&
|
||||
Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var latest) && ReferenceEquals(current, latest))
|
||||
for (var attempt = 0; attempt < MaxProjectedResolveAttempts; attempt++)
|
||||
{
|
||||
if (_disposing || !Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var current)) break;
|
||||
var active = current.Lifetime.IsActive;
|
||||
if (!Volatile.Read(ref _committedProjectedDefinitions).TryGetValue(nodeId, out var latest)) break;
|
||||
if (!ReferenceEquals(current, latest)) continue; // #968: replaced mid-check, not missing
|
||||
if (!active) break;
|
||||
definition = current;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user