fix(redundancy): always publish first ServiceLevel (even 0) + log SafeSelfStatus failures (code-review)
This commit is contained in:
@@ -64,6 +64,7 @@ public sealed class OpcUaPublishActor : ReceiveActor
|
||||
|
||||
private int _writes;
|
||||
private byte _lastServiceLevel;
|
||||
private bool _publishedAtLeastOnce;
|
||||
private DbHealthProbeActor.DbHealthStatus? _lastDbHealth;
|
||||
private RedundancyStateChanged? _lastSnapshot;
|
||||
private Phase7CompositionResult _lastApplied = new(
|
||||
@@ -339,11 +340,15 @@ public sealed class OpcUaPublishActor : ReceiveActor
|
||||
|
||||
private void HandleServiceLevelChanged(ServiceLevelChanged msg)
|
||||
{
|
||||
if (msg.ServiceLevel == _lastServiceLevel) return;
|
||||
// Always publish the FIRST computed level, even if it equals the byte-default 0. Otherwise a
|
||||
// node starting Detached/role-less (first level = 0) would be dedup'd away, leaving the SDK's
|
||||
// built-in default (255 = full service) standing — a degraded node wrongly advertising 255.
|
||||
if (_publishedAtLeastOnce && msg.ServiceLevel == _lastServiceLevel) return;
|
||||
_lastServiceLevel = msg.ServiceLevel;
|
||||
try
|
||||
{
|
||||
_serviceLevel.Publish(msg.ServiceLevel);
|
||||
_publishedAtLeastOnce = true;
|
||||
OtOpcUaTelemetry.ServiceLevelChange.Add(1,
|
||||
new KeyValuePair<string, object?>("level", msg.ServiceLevel));
|
||||
_log.Debug("OpcUaPublish: ServiceLevel={Level}", msg.ServiceLevel);
|
||||
@@ -436,8 +441,9 @@ public sealed class OpcUaPublishActor : ReceiveActor
|
||||
{
|
||||
return _cluster.SelfMember.Status;
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.Debug(ex, "OpcUaPublish: SelfMember status unavailable; treating as Removed (ServiceLevel→0)");
|
||||
return MemberStatus.Removed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user