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:
@@ -601,7 +601,9 @@ instead (#1113 — it used to drop it, so a respawn of an already comms-lost dri
|
||||
the replacement is what must re-publish those refs. Every apply's reindex trims every outstanding latch to the refs the new
|
||||
composition still routes for that driver (`TrimCommsLatchesToIndex`) — a ref the deploy dropped is no longer subscribed and
|
||||
can never be re-published, so it must not be reported — and drops a latch left empty; this runs inside the same apply
|
||||
message as the respawn, so before the replacement's `Connected` can arm the audit. `StopChild` also
|
||||
message as the respawn, so before the replacement's `Connected` can arm the audit. The Warning names the status the nodes
|
||||
actually carry: `still BadNoCommunication`, or `still BadWaitingForInitialData` once a respawn / Restart re-stamped them
|
||||
(#1113). `StopChild` also
|
||||
holds the id in the `ChildHealthLedger` (`Forget` then `Readmit` on the next spawn), so the stopped child's late health
|
||||
publish cannot resurrect its diagnostics entry.
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+4
-3
@@ -192,12 +192,13 @@ public sealed class DriverHostCommsLossRecoveryTests : RuntimeActorTestBase
|
||||
driver.InitializeGate = release.Task;
|
||||
host.Tell(new RestartDriver("c1", "drv-restart", "test-operator", Guid.NewGuid()));
|
||||
|
||||
EventFilter.Warning(contains: "still BadNoCommunication")
|
||||
EventFilter.Warning(contains: "ref(s) still")
|
||||
.Expect(0, audit + TimeSpan.FromSeconds(3), () => { }, TestContext.Current.CancellationToken);
|
||||
meter.SumWithTag("driver_instance", "drv-restart").ShouldBe(0);
|
||||
|
||||
// The new incarnation connects, re-subscribes silently, and its own audit reports the ref the restart kept.
|
||||
EventFilter.Warning(contains: "still BadNoCommunication").ExpectOne(audit + ReconnectBudget, () =>
|
||||
// The new incarnation connects, re-subscribes silently, and its own audit reports the ref the restart kept —
|
||||
// naming the status the Restart re-stamped (#1112), not BadNoCommunication (#1113 item 3).
|
||||
EventFilter.Warning(contains: "1 ref(s) still BadWaitingForInitialData").ExpectOne(audit + ReconnectBudget, () =>
|
||||
{
|
||||
driver.InitializeGate = null;
|
||||
release.SetResult();
|
||||
|
||||
+23
-3
@@ -138,7 +138,7 @@ public sealed class DriverHostRespawnValueNodeGapTests : RuntimeActorTestBase
|
||||
|
||||
// flow never re-published. Had the respawn latched it, the audit armed by the replacement's Connected would
|
||||
// report it after AuditDelay.
|
||||
EventFilter.Warning(contains: "still BadNoCommunication")
|
||||
EventFilter.Warning(contains: "ref(s) still")
|
||||
.Expect(0, AuditDelay + TimeSpan.FromSeconds(2), () => { }, TestContext.Current.CancellationToken);
|
||||
meter.SumWithTag("driver_instance", DriverId).ShouldBe(0);
|
||||
|
||||
@@ -151,7 +151,7 @@ public sealed class DriverHostRespawnValueNodeGapTests : RuntimeActorTestBase
|
||||
TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
// ---- #1113 item 2: a config-change respawn of a driver that was ALREADY comms-lost ----
|
||||
// ---- #1113 items 2 + 3: a respawn / Restart of a driver that was ALREADY comms-lost ----
|
||||
|
||||
/// <summary>Long enough that a test can fire the replacement's first value before the audit runs.</summary>
|
||||
private static readonly TimeSpan LongAuditDelay = TimeSpan.FromSeconds(3);
|
||||
@@ -161,6 +161,7 @@ public sealed class DriverHostRespawnValueNodeGapTests : RuntimeActorTestBase
|
||||
/// replacement was never audited — unlike an operator Restart, #1053), trimmed to the refs the new composition
|
||||
/// still carries. The new deployment drops <c>flow</c> and adds <c>temp</c>; the silent replacement is reported
|
||||
/// for exactly <c>speed</c> — not <c>flow</c> (dropped: a false warning) and not <c>temp</c> (never latched).
|
||||
/// Item 3: the warning names the status the nodes carry, <c>BadWaitingForInitialData</c>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void A_config_change_respawn_of_a_comms_lost_driver_audits_the_replacement_for_the_kept_refs_only()
|
||||
@@ -172,7 +173,7 @@ public sealed class DriverHostRespawnValueNodeGapTests : RuntimeActorTestBase
|
||||
using var meter = new MeterRecorder("otopcua.driver.comms_latched_refs");
|
||||
GoCommsLost(oldDriver, host, publish);
|
||||
|
||||
EventFilter.Warning(contains: "1 ref(s) still BadNoCommunication").ExpectOne(
|
||||
EventFilter.Warning(contains: "1 ref(s) still BadWaitingForInitialData").ExpectOne(
|
||||
LongAuditDelay + PresenceBudget,
|
||||
() => DispatchDroppingFlow(host, coordinator, db),
|
||||
TestContext.Current.CancellationToken);
|
||||
@@ -204,6 +205,25 @@ public sealed class DriverHostRespawnValueNodeGapTests : RuntimeActorTestBase
|
||||
meter.SumWithTag("driver_instance", DriverId).ShouldBe(0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #1113 item 3: an operator Restart keeps the latch (#1053), but the Restart re-stamped the nodes
|
||||
/// <c>BadWaitingForInitialData</c> (#1112) — so the audit must not claim they are "still BadNoCommunication".
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void A_restart_of_a_comms_lost_driver_audit_names_the_awaiting_first_value_status()
|
||||
{
|
||||
var oldDriver = new GatedDriver(DriverId);
|
||||
var newDriver = new GatedDriver(DriverId);
|
||||
var (host, publish, _, _) = Arrange(oldDriver, newDriver, LongAuditDelay);
|
||||
SeedGoodFromOldDriver(oldDriver, publish);
|
||||
GoCommsLost(oldDriver, host, publish);
|
||||
|
||||
EventFilter.Warning(contains: "2 ref(s) still BadWaitingForInitialData").ExpectOne(
|
||||
LongAuditDelay + PresenceBudget,
|
||||
() => host.Tell(new RestartDriver("c1", DriverId, "test-operator", Guid.NewGuid())),
|
||||
TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>Takes the old driver comms-lost (Force Reconnect with its re-initialise held forever) and waits for the
|
||||
/// host's latched <c>BadNoCommunication</c> stamp.</summary>
|
||||
private static void GoCommsLost(GatedDriver oldDriver, IActorRef host, TestProbe publish)
|
||||
|
||||
Reference in New Issue
Block a user