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

DefaultResizer does not reisize when ReceiveAsync is used #5327

Closed
ondravondra opened this issue Oct 19, 2021 · 2 comments · Fixed by #5333
Closed

DefaultResizer does not reisize when ReceiveAsync is used #5327

ondravondra opened this issue Oct 19, 2021 · 2 comments · Fixed by #5333
Assignees
Milestone

Comments

@ondravondra
Copy link
Contributor

Version Information
Version of Akka.NET? 1.3.14
Which Akka.NET Modules? core

Describe the bug
I use SmallestMailboxPool with DefaultResizer. In the worker actors I use ReceiveAsync. I noticed that the pool is not resizing even if the ReceiveAsync awaits some long running operation and there are many messages stuck in the mailboxes.
I think the reason is in the DefaultResizer Pressure method, it checks Mailbox.IsScheduled() but the mailbox is Suspended because ReceiveAsync calls ActorTaskScheduler.RunTask that calls dispatcher.Suspend that calls mailbox.Suspend.

To Reproduce
Steps to reproduce the behavior:

  1. Create a ReceiveActor with router using smallest mailbox pool with default resizer and set some upper limit > nrOfInstances
  2. In the ReceiveActor await some long running operation, e.g. Delay
  3. Send many messages to the router
  4. Observe the pool not resizing, e.g. by logging constructor calls
@Aaronontheweb
Copy link
Member

Issue here is that we should probably treat Mailbox.IsSuspended as a busy signal in the resizer / smallestmailbox router.

@Aaronontheweb
Copy link
Member

I guess we'd add a case here to check to see if the Mailbox.IsSuspended is true and if it has more messages queued up than the "pressure" threshold, we should return true here:

if (PressureThreshold == 1)
return cell.Mailbox.IsScheduled() && cell.Mailbox.HasMessages;
if (PressureThreshold < 1)
return cell.Mailbox.IsScheduled() && cell.CurrentMessage != null;
return cell.Mailbox.NumberOfMessages >= PressureThreshold;

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.

3 participants