diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs index 7bcc44101..630c43ece 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs @@ -628,6 +628,17 @@ public sealed class CentralCommunicationActor : ReceiveActor, IWithTimers return; } + if (IsDeliveryOutcomeUnknown(result.FailureStatus)) + { + _log.Warning( + "Mesh: {CommandType} (correlationId={CorrelationId}) delivery outcome unknown to {NodeId} " + + "({Status}: {Detail}) \u2014 the node may have received and applied it; the deploy coordinator's " + + "re-send/ack will settle it (#1107)", + result.CommandType, result.CorrelationId, result.NodeId, + result.FailureStatus, result.FailureDetail); + return; + } + _log.Warning( "Mesh: {CommandType} (correlationId={CorrelationId}) was NOT delivered to {NodeId} " + "({Status}: {Detail}). This actor does not retry it; a deployment is re-sent by the deploy " @@ -637,6 +648,17 @@ public sealed class CentralCommunicationActor : ReceiveActor, IWithTimers result.FailureStatus, result.FailureDetail); } + /// + /// #1116: a gRPC client deadline / cancellation can expire after the node already received (and applied) the + /// command, so Cancelled / DeadlineExceeded (the dispatch also maps a dial timeout to + /// Cancelled) are "outcome unknown", not "not delivered". + /// Statuses such as Unavailable (no connection) guarantee non-delivery. + /// + /// The recorded failure status text, or null. + /// True when delivery may still have happened. + public static bool IsDeliveryOutcomeUnknown(string? failureStatus) + => failureStatus is "Cancelled" or "DeadlineExceeded"; + private void HandleApplyAck(ApplyAck ack) { var coordinator = _coordinator(); diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/Communication/DeliveryOutcomeClassificationTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/Communication/DeliveryOutcomeClassificationTests.cs new file mode 100644 index 000000000..b562ece3c --- /dev/null +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests/Communication/DeliveryOutcomeClassificationTests.cs @@ -0,0 +1,22 @@ +using Shouldly; +using Xunit; +using ZB.MOM.WW.OtOpcUa.ControlPlane.Communication; + +namespace ZB.MOM.WW.OtOpcUa.ControlPlane.Tests.Communication; + +public sealed class DeliveryOutcomeClassificationTests +{ + [Theory] + [InlineData("Cancelled")] + [InlineData("DeadlineExceeded")] + public void Deadline_or_cancel_is_outcome_unknown(string status) + => CentralCommunicationActor.IsDeliveryOutcomeUnknown(status).ShouldBeTrue(); + + [Theory] + [InlineData("Unavailable")] + [InlineData("Unknown")] + [InlineData("InvalidArgument")] + [InlineData(null)] + public void Other_statuses_stay_not_delivered(string? status) + => CentralCommunicationActor.IsDeliveryOutcomeUnknown(status).ShouldBeFalse(); +}