fix(runtime): #995 review — a repair of a degraded apply re-pushes the drivers whose nodes it creates
OpcUaPublishActor reported AddressSpaceRebuilt only after a real full rebuild, so the empty-plan repair of a degraded composition, the #977 R-4 whole-composition re-ensure, and the re-diff after a degraded non-rebuild all reported a clean non-rebuild. The degraded apply's own re-push had run while the node it failed to place was missing; the apply that finally created it skipped the node's driver (fingerprint unchanged), so the node stayed BadWaitingForInitialData until its value changed — forever for a constant. - The publish actor now reports AddressSpaceRebuilt=true when the apply ran a repair pass (either branch) or when the previous apply of any kind ended degraded (final outcome, completion + catalog included); DriverHostActor re-pushes the deploy's skipped drivers on it. A clean apply after the repair reports false again. - DriverLifecycle.md / rules note the widened signal. Tests: DriverHostActorDegradedRepairReseedTests (REAL publish actor: degraded add, degraded rebuild + empty-plan repair, degraded rebuild + R-4 repair; skip still works afterwards) and OpcUaPublishActorApplyOutcomeTests (outcome on both repair branches + after a degraded non-rebuild, with clean-no-op controls) — all six failed before the fix.
This commit is contained in:
@@ -3520,7 +3520,7 @@ public sealed partial class DriverHostActor : ReceiveActor, IWithTimers, IWithUn
|
||||
private void HandleRebuildCompleted(OpcUa.OpcUaPublishActor.RebuildCompleted msg)
|
||||
{
|
||||
SeedSkippedDrivers(msg.Correlation, reseed: msg.AddressSpaceRebuilt || msg.Degraded,
|
||||
msg.Degraded ? "degraded apply" : "full rebuild");
|
||||
msg.Degraded ? "degraded apply" : "full rebuild, or a repair of a previously degraded apply");
|
||||
if (!_pendingAcks.Remove(msg.Correlation, out var pending))
|
||||
{
|
||||
_log.Debug("DriverHost {Node}: address-space outcome for {Correlation} has no held ack (already timed out or superseded); dropping",
|
||||
|
||||
@@ -165,8 +165,11 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
/// Gitea #995 (R-11): <see langword="false"/> only when the apply was a clean NON-rebuild — every node that
|
||||
/// existed before it still exists with its value. <c>DriverHostActor</c> skips the re-subscribe of a driver
|
||||
/// whose desired set and fan-out are unchanged, and re-pushes those drivers when this is <see langword="true"/>
|
||||
/// (a full rebuild recreated their nodes without a value). Defaults to <see langword="true"/> — the
|
||||
/// conservative answer for any producer that does not know.
|
||||
/// (a full rebuild recreated their nodes without a value). Also <see langword="true"/> for a REPAIR pass (the
|
||||
/// empty-plan re-apply of a degraded composition, or the #977 R-4 whole-composition re-ensure) and for any apply
|
||||
/// following a degraded one: those can create nodes the degraded apply failed to place, valueless, whose drivers
|
||||
/// the deploy skipped (#995 R-11 x #977 R-4 review). Defaults to <see langword="true"/> — the conservative answer
|
||||
/// for any producer that does not know.
|
||||
/// </param>
|
||||
public sealed record RebuildCompleted(
|
||||
CorrelationId Correlation, DeploymentId? DeploymentId, bool Degraded, string? DegradedReason,
|
||||
@@ -331,6 +334,19 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
/// that pass is itself clean.
|
||||
/// </summary>
|
||||
private bool _lastAppliedDegraded;
|
||||
|
||||
/// <summary>
|
||||
/// #995 R-11 x #977 R-4 review: the previous apply (of ANY kind, reported or not) was degraded, so nodes it failed
|
||||
/// to place may be created by the next one — after the driver host's post-degraded re-push already ran against
|
||||
/// the missing node. The next apply therefore reports <see cref="RebuildCompleted.AddressSpaceRebuilt"/> so the
|
||||
/// drivers its deploy skipped are re-pushed; otherwise such a node stays BadWaitingForInitialData until its value
|
||||
/// changes (forever for a constant). Set by <see cref="FinishRebuild"/>.
|
||||
/// </summary>
|
||||
private bool _previousApplyDegraded;
|
||||
|
||||
/// <summary>The apply in progress ran a REPAIR pass (re-ensured the whole composition after a degraded one): nodes
|
||||
/// may have been created without a value. Set by <see cref="ApplyPlanCore"/>, consumed by <see cref="FinishRebuild"/>.</summary>
|
||||
private bool _repairPassRan;
|
||||
/// <summary>
|
||||
/// Gitea #977 (R-20): this instance was created by a supervision RESTART, so <see cref="_lastApplied"/> is the
|
||||
/// empty seed while the sink (the node manager, which outlives the actor) still serves the previous instance's
|
||||
@@ -1534,8 +1550,11 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
}
|
||||
|
||||
// #995 R-11: captured before the replay scope is reset — a rebuild (or the applier-less raw-sink rebuild) recreated
|
||||
// every node, so the driver host must re-seed values it skipped re-subscribing.
|
||||
var rebuilt = _applier is null || _replayScope.AllVariables;
|
||||
// every node, so the driver host must re-seed values it skipped re-subscribing. So may a REPAIR pass, or any apply
|
||||
// after a degraded one (#995 R-11 x #977 R-4 review): either can create a node the degraded apply failed to place,
|
||||
// whose driver the deploy skipped because its fingerprint did not change — the node would never get a value.
|
||||
var rebuilt = _applier is null || _replayScope.AllVariables || _repairPassRan || _previousApplyDegraded;
|
||||
_repairPassRan = false;
|
||||
|
||||
// Land what arrived while the plan was in flight on the nodes the apply just created — before the answer,
|
||||
// so "applied" means the deferred first values are on the address space too (review fix C1).
|
||||
@@ -1549,6 +1568,9 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
outcome = (true, "the expected local data catalog could not be activated");
|
||||
}
|
||||
|
||||
// The FINAL outcome (completion and catalog included) decides whether the next apply must re-seed.
|
||||
_previousApplyDegraded = outcome.Degraded;
|
||||
|
||||
if (msg.ReportOutcome)
|
||||
requester.Tell(new RebuildCompleted(msg.Correlation, msg.DeploymentId, outcome.Degraded, outcome.Reason,
|
||||
AddressSpaceRebuilt: rebuilt));
|
||||
@@ -1638,7 +1660,9 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
{
|
||||
// The composition is unchanged but the last apply of it was a degraded
|
||||
// rebuild: re-ensure every node (each Ensure* no-ops on a node that stands) so the
|
||||
// re-deploy actually repairs what that rebuild could not place.
|
||||
// re-deploy actually repairs what that rebuild could not place. A node it now places has no value
|
||||
// and its driver's re-subscribe was skipped (nothing it seeds changed): report it for a re-push.
|
||||
_repairPassRan = true;
|
||||
var repairFailed = _applier!.MaterialiseHierarchy(composition)
|
||||
+ MaterialiseNodes(plan, composition, fullComposition: true);
|
||||
if (repairFailed > 0)
|
||||
@@ -1687,6 +1711,8 @@ public sealed class OpcUaPublishActor : ReceiveActor, IWithTimers
|
||||
// to place is inside _lastApplied and will never appear in a diff again, so a delta-only apply of an unrelated
|
||||
// change used to clear the degraded flag and report clean over a still-partial address space.
|
||||
var repairingDegraded = _lastAppliedDegraded && !outcome.RebuildCalled;
|
||||
// Like the empty-plan repair: what the re-ensure places is valueless, so the skipped drivers must re-push.
|
||||
if (repairingDegraded) _repairPassRan = true;
|
||||
failedNodes += MaterialiseNodes(plan, composition, fullComposition: outcome.RebuildCalled || repairingDegraded);
|
||||
if (outcome.RebuildCalled) _baselineUnknown = outcome.RebuildFailed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user