-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Milestone
Description
Description
QueueProcessingOrder.NewestFirst is used for a stack pattern (FILO), so the newest entry in line always gets processed next. However, when the queue fills up it starts refusing to add new entries, keeping older entries in the queue.
Instead, it should add the new entry to the front and drop the oldest entry from the back.
Reproduction Steps
var limiter = new System.Threading.RateLimiting.ConcurrencyLimiter(
new System.Threading.RateLimiting.ConcurrencyLimiterOptions(
permitLimit: 1, queueProcessingOrder: QueueProcessingOrder.NewestFirst, queueLimit: 2));
var lease1 = limiter.Acquire(); // Succeeds, exhausts permitLimit.
var lease2Task = limiter.WaitAsync(); // Incomplete, queued
var lease3Task = limiter.WaitAsync(); // Incomplete, queued, exhausts queueLimit.
var lease4Task = limiter.WaitAsync();
// Expected: Incomplete, lease2Task completes without acquiring.
// Actual: Completes immediately without acquiring. lease2Task remains queued.
Expected behavior
WaitAsync should queue a new item and drop the oldest item when the queue is full
Actual behavior
WaitAsync does not queue a new item and maintains the oldest item when the queue is full
Regression?
No response
Known Workarounds
No response
Configuration
.NET 7
Other information
No response