fix(grpc-data): H2 review2-2..6 - byte-bounded pages, one deadline, no leaked cursors

Each node's Raw page is clamped from a per-value byte estimate of its catalog type (wide strings/arrays get small
pages plus a continuation) and sub-batches are sized by estimated bytes, so the in-flight read respects
MaxHistoryResponseBytes; AtTime/Processed whose values x estimate exceed the budget are refused per node with a
diagnostic. One deadline per request: nodes not started when it passes are deferred (transport) or BadTimeout
(direct). Every refusal releases the page cursor it was just given; releasing, invalidating or expiring a chunk
releases the page cursor behind it; results are disposed on the exception path. Chunk bindings use per-node details.
OpcUaServer IVT for Runtime.Tests/Host.Tests so tests can hold real page cursors.
This commit is contained in:
Joseph Doherty
2026-11-23 23:16:14 -05:00
parent eb29360d47
commit a3da73e1e7
5 changed files with 231 additions and 66 deletions
@@ -53,6 +53,26 @@ public sealed class GrpcDataOriginHistorySessionTests
sessions.RetainedBytes("a").ShouldBe(0, "clearing a session returns its remainder bytes");
}
[Fact]
public void Releasing_or_expiring_a_chunk_also_releases_the_page_cursor_behind_it()
{
var clock = new ZB.MOM.WW.OtOpcUa.Runtime.Tests.Harness.ManualTimeProvider();
var sessions = new OriginHistorySessions(clock);
var session = sessions.Get(Caller("a"), Channel("1"), 8);
var view = new DataView(new("c", "u", "string", "x"), DataRealm.Raw, null, 0, "x");
byte[] Page() => session.Cursors.Store.Save(new ZB.MOM.WW.OtOpcUa.OpcUaServer.HistoryContinuationState("t", DateTime.UnixEpoch,
DateTime.UnixEpoch, 0, 1) { BoundIdentifier = "x" }, "a", "inc", "h");
var released = session.SaveChunk(new OriginHistorySession.Chunk(view, "k", "i", [], 0, Page(), null, 0, 10), 1000).ShouldNotBeNull();
session.SaveChunk(new OriginHistorySession.Chunk(view, "k", "i", [], 0, Page(), null, 0, 0, Deferred: true), 1000).ShouldNotBeNull();
session.Cursors.Count.ShouldBe(2);
session.Release(released);
session.Cursors.Count.ShouldBe(1, "release dropped the chunk AND its page cursor");
clock.Advance(TimeSpan.FromSeconds(61));
session.ChunkCount.ShouldBe(0);
session.Cursors.Count.ShouldBe(0, "idle expiry of a chunk dropped its page cursor too");
sessions.RetainedBytes("a").ShouldBe(0);
}
[Fact]
public void Remainder_bytes_are_budgeted_per_principal_across_sessions()
{