diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ConditionStateHub.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ConditionStateHub.cs index 2f86912b7..7e6bc3a53 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ConditionStateHub.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Runtime/DataConnections/ConditionStateHub.cs @@ -49,6 +49,8 @@ public sealed class ConditionStateHub : IConditionStateSink public readonly object Gate = new(); public readonly Queue Buffer = new(); public long Floor; + /// The version of the newest buffered record (A2 review N3: a caught-up reader skips the scan). + public long Tail; } private readonly Partition[] _partitions; @@ -111,6 +113,7 @@ public sealed class ConditionStateHub : IConditionStateSink } p.Buffer.Enqueue(record with { Version = version }); + p.Tail = version; return version; } } @@ -154,6 +157,8 @@ public sealed class ConditionStateHub : IConditionStateSink lock (p.Gate) { if (afterVersion < p.Floor) return new ConditionDeltaRead(true, p.Floor, []); + // A2 review N3: a reader at or past the tail has nothing to read — never scan the partition under its gate. + if (afterVersion >= p.Tail) return new ConditionDeltaRead(false, p.Floor, []); var records = new List(); foreach (var r in p.Buffer) {