fix(deploy): #1111 review — cover the held-ack retry guard; clamp deadline_remaining_ms off the wire
- The _pendingAcks.Count == 0 guard (a stale re-send of an older FAILED deployment must not re-apply it while a NEWER apply's Applied ack is held on its address-space outcome) had no test: mutating it to true left every Runtime test green. New test fails under that mutation (the older revision is re-fetched and applied over the newer one, whose held Applied ack then goes out for a rolled-back node). - MeshTransportDtoMapper.FromProto clamps deadline_remaining_ms to [0, 1 day]: a long.MaxValue wire value threw from TimeSpan.FromMilliseconds; a hugely negative one could overflow the node's TimeSpan subtraction in HandleDispatchFromSteady (actor restart = remembered acks lost). - Doc fix: _lastAnsweredDeploymentId is moved by RememberAck only, not by a replay.
This commit is contained in:
+51
@@ -217,6 +217,57 @@ public sealed class DriverHostActorRedispatchTests : RuntimeActorTestBase
|
||||
fetcher.Calls.ShouldBe(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_resend_of_a_failed_deployment_is_not_retried_while_a_NEWER_applys_ack_is_still_held()
|
||||
{
|
||||
// #1111 review: the newer deployment's Applied ack is held on its address-space outcome, so the failed one is
|
||||
// still this node's latest ANSWER — only the held-ack guard stops the stale re-send from re-applying the older
|
||||
// revision over the newer one (and the newer one's held Applied ack then going out for a rolled-back node).
|
||||
var db = NewInMemoryDbFactory();
|
||||
var fetcher = new ScriptedFetcher(null, EmptyArtifact);
|
||||
var coordinator = CreateTestProbe();
|
||||
var publish = CreateTestProbe();
|
||||
var actor = Sys.ActorOf(DriverHostActor.Props(
|
||||
db, TestNode, coordinator.Ref,
|
||||
localRoles: new HashSet<string> { "driver" },
|
||||
deploymentArtifactCache: new NullArtifactCache(),
|
||||
fetchAndCacheMode: true,
|
||||
artifactFetcher: fetcher,
|
||||
opcUaPublishActor: publish.Ref,
|
||||
applyOutcomeTimeout: TimeSpan.FromSeconds(60)));
|
||||
|
||||
var older = new DispatchDeployment(DeploymentId.NewId(), RevA, CorrelationId.NewId());
|
||||
actor.Tell(older);
|
||||
var failed = coordinator.ExpectMsg<ApplyAck>(PresenceBudget, cancellationToken: TestContext.Current.CancellationToken);
|
||||
failed.Outcome.ShouldBe(ApplyAckOutcome.Failed);
|
||||
|
||||
// The newer deployment applies; its Applied ack is HELD (the address-space outcome has not landed).
|
||||
var newer = new DispatchDeployment(DeploymentId.NewId(), RevisionHash.Parse(new string('b', 64)), CorrelationId.NewId());
|
||||
actor.Tell(newer);
|
||||
var rebuild = publish.FishForMessage<OpcUaPublishActor.RebuildAddressSpace>(_ => true, PresenceBudget, cancellationToken: TestContext.Current.CancellationToken);
|
||||
rebuild.DeploymentId.ShouldBe(newer.DeploymentId);
|
||||
fetcher.Calls.ShouldBe(2);
|
||||
|
||||
// A stale re-send of the older, failed deployment: replays Failed, fetches nothing, starts no rebuild.
|
||||
actor.Tell(older with { TargetNodes = [TestNode.Value] });
|
||||
coordinator.ExpectMsg<ApplyAck>(PresenceBudget, cancellationToken: TestContext.Current.CancellationToken)
|
||||
.ShouldBe(failed);
|
||||
coordinator.ExpectNoMsg(Quiet, TestContext.Current.CancellationToken);
|
||||
fetcher.Calls.ShouldBe(2);
|
||||
|
||||
// The held ack is still the newer deployment's, and goes out clean when its outcome lands.
|
||||
actor.Tell(new OpcUaPublishActor.RebuildCompleted(rebuild.Correlation, rebuild.DeploymentId, false, null), publish.Ref);
|
||||
var ack = coordinator.ExpectMsg<ApplyAck>(PresenceBudget, cancellationToken: TestContext.Current.CancellationToken);
|
||||
ack.DeploymentId.ShouldBe(newer.DeploymentId);
|
||||
ack.Outcome.ShouldBe(ApplyAckOutcome.Applied);
|
||||
ack.Degraded.ShouldBeFalse();
|
||||
|
||||
// Positive control: an ORIGINAL dispatch of the older deployment does fetch — the silence above was the guard.
|
||||
actor.Tell(older);
|
||||
publish.FishForMessage<OpcUaPublishActor.RebuildAddressSpace>(r => r.DeploymentId == older.DeploymentId, PresenceBudget, cancellationToken: TestContext.Current.CancellationToken);
|
||||
fetcher.Calls.ShouldBe(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_late_resend_bounds_the_address_space_wait_to_the_deadline_it_carries()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user