Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queue with capacity = int.MaxValue and strategy DropNew still drops items after very small amount is added #6631

Closed
ondravondra opened this issue Apr 3, 2023 · 0 comments · Fixed by #6632

Comments

@ondravondra
Copy link
Contributor

Version Information
Version of Akka.NET? 1.4.28
Which Akka.NET Modules? Akka.Streams

Describe the bug
Hello, I am using Source.Queue(int.MaxValue, OverflowStrategy.DropNew) to create a queue that always accepts new items, but after enqueuing around 64 of them OfferAsync returns Dropped.
I investigated the source code and found that it uses FixedQueue and in its Enqueue method it checks if there are 16 elements (constant) and allocates a dynamic queue like this: var queue = new DynamicQueue(_head); The parameter _head has value of 64. I wonder if this is a bug and should be var queue = new DynamicQueue(Capacity); The problem is that queue IsFull returns _q.IsFull and since _q is now the DynamicQueue and its capacity is now 64 it returns true and the element is dropped.

To Reproduce
Steps to reproduce the behavior:

  1. Create a queue with int.MaxValue limit: Source.Queue<int>(int.MaxValue, OverflowStrategy.DropNew)
  2. Keep adding elements by calling await q.OfferAsync ...
  3. Expect to get QueueOfferResult.Enqueued each time
  4. Get QueueOfferResult.Dropped instead

Expected behavior
The queue should accept all items because of the high limit

Actual behavior
The queue still drops

Environment
GNU/Linux docker or local .net 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants