fix(grpc-data): H3 review D1/D4/D6/D7 — probe cancel, sub-batches, flush wake-up, request-order budget

D1: a caller cancel (the projected deadline) during the connection's capability
probe escaped as RpcException(Cancelled) and faulted the whole HistoryRead; it
is now OperationCanceledException, the probe is capped by HistoryTimeout, and
ProjectedHistoryAccess fails any escaping fault per node (BadTimeout when the
deadline fired) and releases every cursor it owns. D4: calls are sub-batched at
min(the deployed connection's batch, the origin's advertised MaxBatchItems) and
at most one item per 256 B of the remaining assembly budget; a shortfall is
BadTooManyOperations per node, never an endpoint failure. D6: the release flush
is re-armed from a flag under its gate (no lost wake-up) and the stop source is
never disposed under a running flush. D7: calls are runs of consecutive request
positions read in request order, then the budget is charged in request order.
Float32 node over a Double-returning backend reads Good Singles end to end (no
KindMatches defect). Red/green for D1/D4/D7 by mutation; D6's race did not
reproduce red.
This commit is contained in:
Joseph Doherty
2026-11-24 01:48:12 -05:00
parent 585d5079eb
commit 1237e9e6d1
6 changed files with 437 additions and 106 deletions
@@ -134,7 +134,7 @@ internal sealed class LocalDataFixture : IDisposable
bool advanceAuthority = false, string role = "Primary", long servingGeneration = 0, bool nestedCatalog = false, bool nestedUnsCatalog = false,
Func<DataAuthenticatedContext, IDataWriteService>? writes = null, bool denyReadExport = false,
ManualTimeProvider? clock = null, string servingNode = "node-a", string servingIncarnation = "serving-1",
IOriginHistoryPort? history = null)
IOriginHistoryPort? history = null, DataValueKind rawValueKind = DataValueKind.Int32, int maxBatchItems = 100)
{
if (clock is not null) Clock = clock;
Serving = Serving with { NodeId = servingNode, Incarnation = servingIncarnation, Role = role, ServingGeneration = servingGeneration };
@@ -163,7 +163,7 @@ internal sealed class LocalDataFixture : IDisposable
if (denyReadExport) operations &= ~DataOperations.Read;
if (history is not null) operations |= DataOperations.HistoryRead;
var rootMetadata = new DataMetadata(Root, "Plant", "Folder", DataValueKind.Null, -1, [], false, operations, 1, null, null, false);
var rawMetadata = new DataMetadata(Raw, "Speed", "Variable", DataValueKind.Int32, -1, [], true, operations, 1, Ticket.Key.StableSourceId, "rpm", false);
var rawMetadata = new DataMetadata(Raw, "Speed", "Variable", rawValueKind, -1, [], true, operations, 1, Ticket.Key.StableSourceId, "rpm", false);
var unsMetadata = rawMetadata with { View = Uns };
var folder = Root with { Address = Root.Address with { Identifier = "Plant/Driver" }, Subject = "Plant/Driver" };
var unsRoot = Uns with { Address = Uns.Address with { Identifier = "Area" }, Subject = "Area" };
@@ -192,7 +192,7 @@ internal sealed class LocalDataFixture : IDisposable
Catalog = new LocalExportCatalog("cluster", Serving, Activation.CaptureAuthority(), nodes,
[new() { DataExportId = "raw-export", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Raw, RootKind = "RawFolder", RootEntityId = "folder", PrincipalId = "peer", AllowedOperations = operations },
new() { DataExportId = "uns-export", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = nestedUnsCatalog ? "UnsArea" : "UnsTagReference", RootEntityId = nestedUnsCatalog ? "area" : "reference", PrincipalId = "peer", AllowedOperations = operations }]);
var limits = new DataLimits(100, 100, 1_000_000, 100, 10, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
var limits = new DataLimits(100, maxBatchItems, 1_000_000, 100, 10, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
var capabilities = new DataCapabilitiesProvider("cluster", () => Serving, () => Catalog.IsActive, limits);
Services = new LocalDataServices(() => Catalog, Hub, new DataOperationPolicy(Authority,
new TriePermissionEvaluator(Authority.Tries, Clock), Clock), capabilities, Clock, writes: writes, subscriptions: subscriptions,