fix(grpc-data): A2 review B1 — a full condition queue back-pressures instead of resetting the stream

budget = Max(1, …) pulled a chunk on a full queue every 100 ms tick, TryWrite failed and the stream was
reset, so a backlog above MaxPendingFrames chunks never completed its snapshot. Max(0, …) produces
nothing until the consumer drains. Test: 25-chunk backlog, stalled sink, 20 ticks ⇒ no reset, snapshot
completes (red before).
This commit is contained in:
Joseph Doherty
2026-11-24 14:48:28 -05:00
parent fbf9f7b898
commit 69014cc4f8
2 changed files with 20 additions and 1 deletions
@@ -119,6 +119,23 @@ public sealed class GrpcDataConditionStreamTests
reset.Diagnostic.ShouldNotBeNull().ShouldContain("overflow");
}
[Fact]
public async Task A_backlog_above_the_pending_frame_limit_back_pressures_a_stalled_sink_instead_of_resetting()
{
// 3,000 records = 24 record chunks + a begin chunk, above the session's 16 pending frames (review B1).
using var f = new ConditionFixture(conditions: 3000, maxConditions: 5000);
await using var stream = await f.OpenAsync();
await stream.ReadAckAsync();
// The sink stalls: nothing is read while the session's 100 ms tick keeps running the pump on a full queue.
for (var i = 0; i < 20; i++) { f.Tick(); await Task.Delay(25, Ct); }
var snapshot = await stream.ReadSnapshotAsync();
snapshot.Begin.Total.ShouldBe(3000);
snapshot.Records.Count.ShouldBe(3000);
snapshot.Complete.ShouldBeTrue("the snapshot completes once the sink drains");
stream.Ended.ShouldBeFalse("a full queue is back-pressure, not a stream reset");
f.StreamOf(stream)!.Snapshots.ShouldBe(1);
}
[Fact]
public async Task Delivery_priority_is_control_then_condition_then_value()
{