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

Inbox.Receive always gives an ArgumentOutOfRangeException #1694

Closed
Oipo opened this issue Feb 7, 2016 · 6 comments
Closed

Inbox.Receive always gives an ArgumentOutOfRangeException #1694

Oipo opened this issue Feb 7, 2016 · 6 comments

Comments

@Oipo
Copy link

Oipo commented Feb 7, 2016

The following code always gives an exception on akka 1.0.6.

using (var system = ActorSystem.Create("System"))
{
  var inbox = Inbox.Create(system);
  while(true)
  {
    var message = inbox.Receive();
  }
}
[ERROR][2/7/2016 10:34:39 PM][Thread 0009][akka://DispatchSystem/system/inbox-1] Delay must be >=0. It was -00:00:00.0010000
Parameter name: delay
Cause: System.ArgumentOutOfRangeException: Delay must be >=0. It was -00:00:00.0010000
Parameter name: delay
  at Akka.Actor.SchedulerBase.ValidateDelay (TimeSpan delay, System.String parameterName) <0x412a4130 + 0x000bb> in <filename unknown>:0 
  at Akka.Actor.SchedulerBase.Akka.Actor.ITellScheduler.ScheduleTellOnce (TimeSpan delay, ICanTell receiver, System.Object message, IActorRef sender, ICancelable cancelable) <0x412cc660 + 0x00037> in <filename unknown>:0 
  at Akka.Actor.SchedulerExtensions.ScheduleTellOnceCancelable (IScheduler scheduler, TimeSpan delay, ICanTell receiver, System.Object message, IActorRef sender) <0x412cc5b0 + 0x0007c> in <filename unknown>:0 
  at Akka.Actor.InboxActor.Receive (System.Object message) <0x412ca770 + 0x0064b> in <filename unknown>:0 
  at Akka.Actor.ActorBase.AroundReceive (Akka.Actor.Receive receive, System.Object message) <0x4126a310 + 0x00024> in <filename unknown>:0 
  at Akka.Actor.ActorCell.ReceiveMessage (System.Object message) <0x41269fa0 + 0x0005b> in <filename unknown>:0 
  at Akka.Actor.ActorCell.Invoke (Envelope envelope) <0x412698b0 + 0x001fb> in <filename unknown>:0 
@Horusiath
Copy link
Contributor

This is actual place where error occurs. It looks like measuring time left based on scheduler's monotonic clock isn't free of issues - my guess (unconfirmed) is that time resolution unit for monotonic clock is millisecond.

Other question is: do we really have to put non-zero requirement on scheduler delay? @akkadotnet/core ?

@JeffCyr
Copy link
Contributor

JeffCyr commented Feb 12, 2016

The InboxActor should reply a Status.Failure immediately if the delay is <= 0.

The inbox default-timeout is 5s, to get this error, the timeout have to be set to 0s which would make the Inbox useless.

@Oipo Did you change the default-timeout in the App.Config of your test application?

@JeffCyr JeffCyr self-assigned this Feb 12, 2016
@Oipo
Copy link
Author

Oipo commented Feb 12, 2016

@JeffCyr I've been using the following config.

I didn't even know that there's a default-timeout option, let alone change it.

@JeffCyr
Copy link
Contributor

JeffCyr commented Feb 12, 2016

I can reproduce the issue if I set the inbox timeout to 0s. This issue can also occur with the default setting (5s) if the InboxActor is jammed and can't process the message before the receive timeout.

I'll create a Pull Request to address this issue, but there is still something weird with your system (either a 0s timeout or a jammed InboxActor).

@JeffCyr
Copy link
Contributor

JeffCyr commented Feb 12, 2016

PR #1702

@Oipo
Copy link
Author

Oipo commented Feb 12, 2016

You're right that there's something else going on, I cannot reproduce the issue with just one instance running. As soon as a second one (the remote in /remoteactor) connects, the inbox shows the issue in my first post. Pardon me for not giving a proper test case.

Thanks for the fix though.

Aaronontheweb added a commit that referenced this issue Feb 16, 2016
#1694 Added safe check in InboxActor when receive timeout is already expired
@JeffCyr JeffCyr closed this as completed Mar 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants