fix(grpc-data): H3 review round 3 S4 — budget stop keys on a typed consumer marker, not the diagnostic

ProjectedHistoryAccess stopped the request on any BadTooManyOperations whose
diagnostic contained "budget", which also matched the ORIGIN's "remainder
budget is full" refusal and then refused later nodes, including Good ones.
DataHistoryReadResult gains an internal ConsumerBudgetRefused flag (never on
the wire) set only by the gRPC connection's own assembly refusal. Red on
revert: the origin refusal of A refused B.
This commit is contained in:
Joseph Doherty
2026-11-24 07:01:28 -05:00
parent 7aaa98751a
commit 34e72de3d8
5 changed files with 50 additions and 6 deletions
@@ -259,7 +259,7 @@ public sealed partial class GrpcDataConnection : IDataHistoryService
{
// The per-request assembly budget is exhausted: this and every later node is BadTooManyOperations.
_ = ReleaseOnEndpointAsync(selected, result.Continuation);
final[target] = new(result.CorrelationId, BadTooManyOperations, [], null, "History assembly budget exceeded.");
final[target] = new(result.CorrelationId, BadTooManyOperations, [], null, "History assembly budget exceeded.") { ConsumerBudgetRefused = true };
continue;
}
if (result.ChunkContinues)
@@ -304,10 +304,13 @@ public sealed class ProjectedHistoryAccess : IProjectedHistoryAccess, IDisposabl
continue; // its token (if any) is released in the finally
}
if (answer.StatusCode == BadTooManyOperations && answer.Diagnostic?.Contains("budget", StringComparison.OrdinalIgnoreCase) == true)
if (answer.StatusCode == BadTooManyOperations && answer.ConsumerBudgetRefused)
{
assemblyRefused[i] = true; // the connection's own share of the assembly budget ran out:
budgetExhausted = true; // no further origin call in this request (H3 review round 2)
// The connection's own share of the assembly budget ran out: no further origin call in this
// request (H3 review round 2). A typed marker, never the diagnostic text — an ORIGIN's refusal
// ("remainder budget is full") is a per-node answer, not a spent request (round 3, S4).
assemblyRefused[i] = true;
budgetExhausted = true;
}
long nodeBytes = 0;
foreach (var sample in answer.Samples) nodeBytes += sample.Value.EstimatedRetainedBytes;