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
@@ -89,7 +89,13 @@ public sealed partial class GrpcDataConnection : IDataHistoryService
Check();
cancellationToken.ThrowIfCancellationRequested();
Selected selected;
try { selected = await SelectAsync(_endpoints[index], start, request.Budget, false, cancellationToken).ConfigureAwait(false); ProbeSucceeded(); }
// The capability probe is capped by HistoryTimeout too (H3 review), like every history call.
try { selected = await SelectAsync(_endpoints[index], start, ProbeBudget(request.Budget), false, cancellationToken).ConfigureAwait(false); ProbeSucceeded(); }
catch (Exception ex) when (cancellationToken.IsCancellationRequested && ex is RpcException or OperationCanceledException)
{
// A caller cancel (a deadline) during the probe is a cancel, never an escaping RpcException (H3 review D1).
throw new OperationCanceledException("History read cancelled by the caller.", ex, cancellationToken);
}
catch (Exception ex) when (!cancellationToken.IsCancellationRequested
&& ex is RpcException or InvalidOperationException or UnauthorizedAccessException or HttpRequestException or TimeoutException or ArgumentException)
{ failure = ex; RecordFailure(ex); continue; }
@@ -291,6 +297,9 @@ public sealed partial class GrpcDataConnection : IDataHistoryService
catch (Exception ex) when (ex is RpcException or OperationCanceledException or InvalidOperationException) { }
}
/// <summary>The capability probe's budget: the caller's, capped by <see cref="HistoryTimeout"/>.</summary>
private DataBudget ProbeBudget(DataBudget budget) => budget.Timeout <= HistoryTimeout ? budget : budget with { Timeout = HistoryTimeout };
private static DataHistoryReadResult[] All(DataHistoryReadRequest request, uint status) =>
request.Items.Select(x => new DataHistoryReadResult(x.CorrelationId, status, [], null)).ToArray();