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:
+3
-1
@@ -135,7 +135,9 @@ internal sealed partial class DataSubscriptionSession
|
||||
}
|
||||
if (items.Length == 0) return Task.CompletedTask;
|
||||
var queue = ConditionOutbound;
|
||||
var budget = Math.Max(1, _limits.MaxPendingFrames - queue.Reader.Count);
|
||||
// Review B1: a full queue is back-pressure — produce nothing (the dequeue re-ticks the pump). Never pull a chunk
|
||||
// that cannot be queued: the stream would then have to reset on every tick while the backlog drains.
|
||||
var budget = Math.Max(0, _limits.MaxPendingFrames - queue.Reader.Count);
|
||||
var idle = 0;
|
||||
while (budget > 0 && idle < items.Length && Volatile.Read(ref _closing) == 0 && Volatile.Read(ref _closed) == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user