fix(runtime): #1113 the comms-recovery audit names the status the latched nodes actually carry
Item 3. After a respawn / Restart re-stamped a comms-lost driver's nodes BadWaitingForInitialData (#1112), the kept-latch audit still said the refs were 'still BadNoCommunication'. The host now records that the latched nodes were re-stamped (_commsLatchReplaced; cleared with the latch and by a fresh comms-loss stamp) and the Warning reads 'still BadWaitingForInitialData' in that case, 'still BadNoCommunication' otherwise. Tests: new Restart-of-a-comms-lost-driver case; the #1053 Restart test and the item-2 test expect the new wording; the no-audit absence checks match any 'ref(s) still' so they cannot pass vacuously on the wording change.
This commit is contained in:
@@ -689,6 +689,14 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, HashSet<string>> _commsLatched = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>
|
||||
/// Gitea #1113 item 3: drivers whose <see cref="_commsLatched"/> refs were re-stamped
|
||||
/// <see cref="OpcUaStatus.BadWaitingForInitialData"/> by a respawn / Restart after the comms-loss stamp
|
||||
/// (<see cref="StampValueNodesAwaitingNewDriver"/>), so the recovery audit names the status those nodes
|
||||
/// actually carry. Cleared with the latch and by a fresh comms-loss stamp.
|
||||
/// </summary>
|
||||
private readonly HashSet<string> _commsLatchReplaced = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>Per-driver rate limit for the supervision-reprovision hook (see
|
||||
/// <see cref="DefaultReprovisionBackoff"/>).</summary>
|
||||
private readonly TimeSpan _reprovisionBackoff;
|
||||
@@ -2348,6 +2356,8 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
var latched = new HashSet<string>(entries.Count, StringComparer.Ordinal);
|
||||
foreach (var (rawPath, _) in entries) latched.Add(rawPath);
|
||||
_commsLatched[driverInstanceId] = latched;
|
||||
// The nodes carry BadNoCommunication again, whatever a respawn stamped before.
|
||||
_commsLatchReplaced.Remove(driverInstanceId);
|
||||
|
||||
// A previous reconnect's audit is now meaningless — this driver is down again.
|
||||
Timers.Cancel(CommsAuditTimerKey(driverInstanceId));
|
||||
@@ -2384,11 +2394,12 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
|
||||
private static string CommsAuditTimerKey(string driverInstanceId) => $"comms-audit:{driverInstanceId}";
|
||||
|
||||
/// <summary>Drops <paramref name="driverInstanceId"/>'s comms-loss latch.</summary>
|
||||
/// <summary>Drops <paramref name="driverInstanceId"/>'s comms-loss latch and its replaced marker.</summary>
|
||||
/// <param name="driverInstanceId">The driver whose latch ends.</param>
|
||||
private void ForgetCommsLatch(string driverInstanceId)
|
||||
{
|
||||
_commsLatched.Remove(driverInstanceId);
|
||||
_commsLatchReplaced.Remove(driverInstanceId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2444,6 +2455,12 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
return;
|
||||
}
|
||||
|
||||
// #1113 item 3: a respawn / Restart since the outage re-stamped those nodes awaiting-first-value — name the
|
||||
// status they actually carry.
|
||||
var latchedStatus = _commsLatchReplaced.Contains(msg.DriverInstanceId)
|
||||
? nameof(OpcUaStatus.BadWaitingForInitialData)
|
||||
: nameof(OpcUaStatus.BadNoCommunication);
|
||||
|
||||
var driverType = _children.TryGetValue(msg.DriverInstanceId, out var child) ? child.DriverType : "unknown";
|
||||
OtOpcUaTelemetry.DriverCommsLatchedRefs.Add(
|
||||
latched.Count,
|
||||
@@ -2451,11 +2468,14 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
new KeyValuePair<string, object?>("driver_type", driverType));
|
||||
|
||||
_log.Warning(
|
||||
"DriverHost {Node}: driver {Driver} ({Type}) — {Count} ref(s) still BadNoCommunication {Delay} after reconnect; "
|
||||
"DriverHost {Node}: driver {Driver} ({Type}) — {Count} ref(s) still {Status} {Delay} after reconnect; "
|
||||
+ "the driver did not re-publish them (missing initial push, or a value-only dedup swallowed an unchanged value). "
|
||||
+ "First: {First}",
|
||||
_localNode, msg.DriverInstanceId, driverType, latched.Count, _commsRecoveryAuditDelay,
|
||||
latched.OrderBy(r => r, StringComparer.Ordinal).First());
|
||||
new object[]
|
||||
{
|
||||
_localNode, msg.DriverInstanceId, driverType, latched.Count, latchedStatus, _commsRecoveryAuditDelay,
|
||||
latched.OrderBy(r => r, StringComparer.Ordinal).First(),
|
||||
});
|
||||
|
||||
ForgetCommsLatch(msg.DriverInstanceId);
|
||||
}
|
||||
@@ -5391,6 +5411,8 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
|
||||
if (writes.Count == 0) return;
|
||||
_opcUaPublishActor.Tell(new OpcUa.OpcUaPublishActor.AttributeStatusBatchUpdate(writes));
|
||||
// #1113 item 3: an outstanding comms latch now names nodes carrying THIS status, not BadNoCommunication.
|
||||
if (_commsLatched.ContainsKey(driverInstanceId)) _commsLatchReplaced.Add(driverInstanceId);
|
||||
_log.Info(
|
||||
"DriverHost {Node}: driver {Driver} object replaced — {Count} value node(s) marked BadWaitingForInitialData until its first value",
|
||||
_localNode, driverInstanceId, writes.Count);
|
||||
|
||||
Reference in New Issue
Block a user