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

Ask should push unhandled answers into deadletter #5221

Merged

Conversation

Zetanova
Copy link
Contributor

Currently invalid or timed out answers of Ask getting invisibly ignored by FutureActorRef
This PR will push all invalid answers into deadletter.
Invalid answers are timeout-answer, too many answers, answer in a bad state of FutureActorRef.

The only exception is a canceled Ask, this answer will still be ignored.

@Aaronontheweb Aaronontheweb added this to the 1.4.25 milestone Aug 25, 2021
@Aaronontheweb Aaronontheweb self-requested a review August 25, 2021 20:00
@Aaronontheweb
Copy link
Member

I'll take a look!

@Zetanova
Copy link
Contributor Author

Zetanova commented Aug 26, 2021

sry, for the micro commits

Perf. increase for sealed classes
https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-6/#peanut-butter

This does not apply for IActorRef and ICanTell
but maybe for a future type some help to decide to use Interfaces or sealed classes

@Zetanova
Copy link
Contributor Author

Akka.Actor.Failure is unused and mutable, should it not be obsoleted?
I think everything is using Akka.Actor.Status.Failure

@Zetanova
Copy link
Contributor Author

For the Akka.Actor.Failure issue the PR is found at #5226

@Aaronontheweb
Copy link
Member

but maybe for a future type some help to decide to use Interfaces or sealed classes

that takes me back to 2014, when I argued for using an ActorRef base class rather than an IActorRef interface - but I lost that argument unfortunately :p

@Zetanova
Copy link
Contributor Author

Zetanova commented Aug 31, 2021

Your view has been 100% on point, virt calls have a coast.
This has most of the time absolutely no impack.

But for IActorRef.Tel(msg) it has ... for sure.

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about thread-safety and re-entrancy ehere

{
if (Interlocked.Exchange(ref status, COMPLETED) == INITIATED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we lose thread-safety without this? What happens if multiple threads try to complete the same Ask at the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskCompletionSource<T> _result is thread-safe, the barrier is not needed.

@@ -121,43 +104,37 @@ public override IActorRefProvider Provider
/// <param name="sender">TBD</param>
protected override void TellInternal(object message, IActorRef sender)
{
var handled = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled is a local variable, so if we attempt to send multiple messages to this FutureActorRef<T> this will evaluate to true each time, will it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskCompletionSource<T> _result is thread-safe handled tracks if the current message could be set as the task result.

Copy link
Contributor Author

@Zetanova Zetanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aaronontheweb What is missing and what question is unanswered?

@@ -121,43 +104,37 @@ public override IActorRefProvider Provider
/// <param name="sender">TBD</param>
protected override void TellInternal(object message, IActorRef sender)
{
var handled = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskCompletionSource<T> _result is thread-safe handled tracks if the current message could be set as the task result.

{
if (Interlocked.Exchange(ref status, COMPLETED) == INITIATED)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TaskCompletionSource<T> _result is thread-safe, the barrier is not needed.

}
}
case ISystemMessage sysM:
SendSystemMessage(sysM); //we have special handling for system messages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would throw an exception here - not supposed to send any system messages to temporary actors

@Aaronontheweb
Copy link
Member

@Zetanova thanks! That answers both of those questions - only one last issue and then I think we're good to go:

https://github.com/akkadotnet/akka.net/pull/5221/files#r703000593

Would you mind submitting a new PR that implements that? Sorry for the screw-up here, again

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

Successfully merging this pull request may close these issues.

2 participants