These are chat archives for akkadotnet/akka.net

21st
Mar 2018
yoav
@bernoli
Mar 21 2018 09:21

I hope this is the right place if not I am sorry in advance. I want to ask about shards, I am trying to add custom supervisor strategy to my entity actors. I want shards actors to still be able to resume, stop etc even though they are controlled by the shard region but I found no reference for it, the example setup does not put the supervision on at the parent of the entity actor i.e. in the example I want TaskActor to be supervised:

var region = ClusterSharding.Get(this.System)
                    .Start(typeof(TaskActor).Name,
                        Props.Create<TaskActor>()
                            .WithSupervisorStrategy(defaultSupervisorStrategy),
                        ClusterShardingSettings.Create(this.System),
                        new TaskActor.TaskMessageExtractor());

And thanks for all the amazing people working on this project, it is amazing.

Havret
@Havret
Mar 21 2018 11:02
Is there any way to subscribe shard proxy to distributed pub sub?
Hyungho Ko
@hhko
Mar 21 2018 14:20
Hi. An actor is usually running different thread while receiving messages.
however I want to run the specific actor running all the same thread while receiving messages
how to set configuration for it?
Marc Piechura
@marcpiechura
Mar 21 2018 14:23
@hhko you probably want to use a dedicated dispatcher for those actors, see http://getakka.net/articles/actors/dispatchers.html
Hyungho Ko
@hhko
Mar 21 2018 14:27
<akka>
<hocon>
<![CDATA[
my-dispatcher {
type = PinnedDispatcher
}

akka {
actor{
deployment{
/HelloActor {
dispatcher = my-dispatcher
}
}
}
}
]]>
</hocon>
</akka>
@marcpiechura is it right?
Marc Piechura
@marcpiechura
Mar 21 2018 14:32
Doesn’t look wrong at least, but I haven’t configured a dispatcher before so I’m not 100% sure
Hyungho Ko
@hhko
Mar 21 2018 14:33
@marcpiechura thank you for your consideration. i'm going to test it. ^^;;;
Marc Piechura
@marcpiechura
Mar 21 2018 14:34
You‘re welcome
Aaron Stannard
@Aaronontheweb
Mar 21 2018 15:16
@Havret yeah, should be able to call the DistributedPubSub.Get code from inside the PreStart routine of the sharded entity
that will let you access the mediator, and you can subscribe from there
Havret
@Havret
Mar 21 2018 16:03
@Aaronontheweb But that way I will subscribe in each sharded entity. :(
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:03
ohhh my bad
you meant the shardProxy
yeah in that case, in the same block of code where you get the shard proxy just do that
and send the Subscribe message to the mediator with the shard proxy's IActorRef
Havret
@Havret
Mar 21 2018 16:04
Doesn't it double my messages?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:04
Subscribe is idempotent
oh I see though
you'll have a message pushed for every shard proxy
yeah that won't work then
might need to use the groups feature in DistributedPubSub
and limit your publish operation to 1 group only
Havret
@Havret
Mar 21 2018 16:06
That's the idea.
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:06
either that or have a dedicated cluster singleton of the same role type as your shard host
Havret
@Havret
Mar 21 2018 16:06
I have implemented this with cluster singleton for now.
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:06
and have that subscribe the shard region inside the same node as itself
the idea here, I assume
is to be able to CREATE the entities via DPS
by sending those messages through the proxies and regions
right?
Havret
@Havret
Mar 21 2018 16:07
yep
thanks
Onur Gumus
@OnurGumus
Mar 21 2018 16:38
Does the message ordering guarantee still hold when I tell messages to an actor directly? Because I have an actor and I send two messages to it from my Main function and it is receiving those in random order.
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:38
if you tell two messages in a row to an IActorRef from within the same context
they will be received in that order
Onur Gumus
@OnurGumus
Mar 21 2018 16:38
It is not. in my case
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:39
because the Tell method can't exit until the message is queued into the actor's mailbox
or in the case of Akka.Remote, until the message is queued into the mailbox of the EndpointWriter
Onur Gumus
@OnurGumus
Mar 21 2018 16:39
    let commandHandler = sys.ActorOf(props,"CommandHandler")
    commandHandler.Tell(SetBalance("1",2000M))
    commandHandler.Tell(SetBalance("2",3000M))
Command Handler is a local actor
when I put breakpoint to my handler I sometimes see "1" comes first and some times "2"
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:40
what does the SetBalanace function do? Is it just a tuple type?
<-- only uses F# for FAKE
Onur Gumus
@OnurGumus
Mar 21 2018 16:40
it is a class
think of it is like new SetBalance(...)
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:41
you're doing weird shit somewhere then
Onur Gumus
@OnurGumus
Mar 21 2018 16:41
my code is too simple to do weird shit
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:41
Akka.NET's message ordering guarantee has been thoroughly battle tested
Onur Gumus
@OnurGumus
Mar 21 2018 16:41
I thought it works fine if I send a message from actor A to B.
But this is not from an actor but directly from main.
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:42
it'll work fine in this context too
Onur Gumus
@OnurGumus
Mar 21 2018 16:42
this behavior is not documented.
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:42
because the Tell method literally can't proceed until the message is queued
and once its queued, nothing can jump the line in front of it
it's literally just a ConcurrentQueue backing this
Onur Gumus
@OnurGumus
Mar 21 2018 16:42
hmm I wonder if there is a way to debug
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:44
good lord
so, can you please post a SS of the signature on that Tell method
https://github.com/akkadotnet/akka.net/blob/dev/src/core/Akka.FSharp/FsApi.fs#L71 - because if this is how it's implemented in the F# API
that would explain a lot
should just be void
if it's returning a Task or an awaitable or whatever
that would explain what you're seeing
Onur Gumus
@OnurGumus
Mar 21 2018 16:45
no I am not using any F# api
it is void
I am using plain old akka api
and it is really random
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:46
no Akka.FSharp?
Onur Gumus
@OnurGumus
Mar 21 2018 16:46
no Akka.Fsharp
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:46
k
so what I'm saying is
all this method is doing
is sticking something in a ConcurrentQueue
that's it
Onur Gumus
@OnurGumus
Mar 21 2018 16:46
I understand you have strong statements. But I have my breakpoint and and each time it hits 1 or 2 randomly
hmm wait a sec
@Aaronontheweb this actor is a persistent one, I deleted it's events now it is always the first one
Onur Gumus
@OnurGumus
Mar 21 2018 16:52
By some means can recovery interfere with the order?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:52
can you post the code?
of what the actor looks like?
(even if you have to simplify it)
because no, not really - unless you're using PersistAsync
when processing new messages
which would absolutely mess with the order
Onur Gumus
@OnurGumus
Mar 21 2018 16:53
oh I think this is another PEBKAC case
darn
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:53
PersistAsync eh?
Onur Gumus
@OnurGumus
Mar 21 2018 16:53
problem is between keybord and chair
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:53
difference between that and a normal Persist is that PersistAsync doesn't enforce strong ordering
Onur Gumus
@OnurGumus
Mar 21 2018 16:54
I meant it is my stupidity
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:54
PersistAsync can allow multiple persist operations concurrently
lol
no worries
Onur Gumus
@OnurGumus
Mar 21 2018 16:54
I had two methods with the same name
and I put the breakpoint to wrong one
that's how F# is.
since you have all your classes in 1 file
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:55
glad I was able to help
lol
Onur Gumus
@OnurGumus
Mar 21 2018 16:55
though the order in the database definitely is different
that is normal right ?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:56
the way stuff gets replayed in Akka.Persistence is based on the SeqNo
unless you have a third party driver that someone goofed on
reminds me - @jackowild I owe you a look at the rebased Mongo driver
(since we are trying to update that driver)
I've been tied up working on some Docker infrastructure for Akka.Cluster most of this week
Onur Gumus
@OnurGumus
Mar 21 2018 16:57
I have seen the post
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:57
almost done with it
Onur Gumus
@OnurGumus
Mar 21 2018 16:57
but I couldn't understand why it is significant
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:57
which stuff?
Onur Gumus
@OnurGumus
Mar 21 2018 16:57
docker
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:57
the akkabootstrap-docker?
that I posted in chat last night?
Onur Gumus
@OnurGumus
Mar 21 2018 16:57
not sure, I am referring to the thing you are working on about docke
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:57
oh that
Onur Gumus
@OnurGumus
Mar 21 2018 16:57
I think I saw it on twitter
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:57
yeah that's the same thing
basically we're shipping some examples of how to construct clusters using docker and docker-compose
and some tools that make it easy for Akka.Cluster nodes to do all of the bootstrapping they need over a docker vnet
which includes some standard Dockerfile templates
Onur Gumus
@OnurGumus
Mar 21 2018 16:58
hmm I see
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:59
mostly it's solving issues related to "what is my IP," "who are my seed nodes," and "how do I contact them?"
using some environment variables, bash scripts, and configuration injection in HOCON
yoav
@bernoli
Mar 21 2018 16:59
This sound great (Docker thing)
Aaron Stannard
@Aaronontheweb
Mar 21 2018 16:59
it's a tiny amount of code ultimately
Onur Gumus
@OnurGumus
Mar 21 2018 16:59
I have another question. I am using a cluster singleton for recovery. These nodes run on the same PC. I want the recovery to happen is fast as possible.
I set auto down to 0s, and hand-over-tries to 0
but I still see 9 dead letters before the hand over
yoav
@bernoli
Mar 21 2018 17:00
Could take akka to a greater place, cloud?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:00
the dead letters stuff is usually innocuous
it's going to happen when nodes leave or die
since actor references are getting terminated
Onur Gumus
@OnurGumus
Mar 21 2018 17:01
yes I am fine with it, but does the hand over wait for 10 dead letters ?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:01
oh, no
it doesn't
it waits for some cluster events to come in
Onur Gumus
@OnurGumus
Mar 21 2018 17:01
I want my singleton to kick in as fast as possible
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:01
signaling that the node is down
Onur Gumus
@OnurGumus
Mar 21 2018 17:01
since they are on the same machine 0s is good for me
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:01
@bernoli yep, it should
Onur Gumus
@OnurGumus
Mar 21 2018 17:02
is there a way to make any faster than setting auto down to 0s ?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:02
Azure container services, DC/OS, and K8s are the most highly requested runtime environments
@OnurGumus one idea, but it depends on how your singleton works
rather than letting Akka.NET automate this for you via ClusterSingleton, which may not be "fast" enough for that scenario
since there's latencies involved in how the Akka.Cluster engine detects / reports on stuff and how the singleton hand-off works
might want to setup something that looks like active-passive failover for actors
there are only two nodes in the cluster?
or are there more than that?
Onur Gumus
@OnurGumus
Mar 21 2018 17:04
it is a dummy singleton. This is for the Passport scanners devices for the airport. These devices have some native code and sometimes borks CLR itself. So the backup process kicks in and rescans the passport.
in case first CLR dies
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:04
ohhhhh
I see
and you can't run more than one copy of the "singleton" at a time?
like, it's not possible for multiple nodes to all run a copy of this at once?
Onur Gumus
@OnurGumus
Mar 21 2018 17:04
the device can only connect to one CLR
David Rivera
@mithril52
Mar 21 2018 17:04
@Aaronontheweb I am getting a circumstance where I get an error message like this: Association to [akka.tcp://NmsClient@172.17.252.193:58417] having UID [1903034288] is irrecoverably failed. UID is now quarantined and all messages to this UID will be delivered to dead letters. Remote actorsystem must be restarted to recover from this situation
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:05
I see
David Rivera
@mithril52
Mar 21 2018 17:05
@Aaronontheweb Oops, hit enter on accident...is there anyway for the client side to know this needs to happen?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:05
yes there is
there's an event that we publish to the EventStream
that you can subscribe to
David Rivera
@mithril52
Mar 21 2018 17:06
Aha
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:06
which tells you "yeah, you should probably restart"
let me find it
David Rivera
@mithril52
Mar 21 2018 17:06
That would be perfect
ThisActorSystemQuarantinedEvent
"someone is mad at you"
Onur Gumus
@OnurGumus
Mar 21 2018 17:06
Speaking of EventStream, we need Subchannels for local even pub subs
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:07
you only get quarantined if a system message is failed to be delivered over Akka.Remote
99% of the time it's a Terminated or some other deathwatch message
but it can also be something like a Stop command used for killing an actor
we have a reliable delivery system in-place to ensure that those deliveries can happen even across unstable connections
but eventually Akka.Remote will give up if it's failed several times in a row
David Rivera
@mithril52
Mar 21 2018 17:08
I'm getting it in a situation where a client is connected to the cluster on a laptop, and the laptop switches from its Ethernet over to wi-fi
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:08
which is when that happens
@OnurGumus the EventStream is pretty coarse-grained
topics are CLR types
theoretically, should be able to use something like a DU in F#
Onur Gumus
@OnurGumus
Mar 21 2018 17:09
What do you suggest, should I roll my own event stream?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:09
nah, I'd suggest coming up with some way of differentiating the stream via types if you want to use the local EventStream
either that or roll your own actors that do pub-sub via a string-based topic system
or you could use DistributedPubSub for that, in theory
Onur Gumus
@OnurGumus
Mar 21 2018 17:10
I don't want to run a cluster for this thing only
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:10
@mithril52 yeah that sounds like the sort of thing that would make Akka.Remote grumpy
since the network interface is changing
Onur Gumus
@OnurGumus
Mar 21 2018 17:11
We also need passivation without sharding
or even without clusters
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:11
passivation without sharding
been looking at that for a specific project recently
Onur Gumus
@OnurGumus
Mar 21 2018 17:11
right know I am doing my own poor man's passivation where parent book keeps the counts per child
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:12
best generic way of doing that
is to have a "passivate" command message
which starts the passivation process for any selected actors
the parent actor of those affected actors
knows to not route any new work to those children
managerger
@managerger
Mar 21 2018 17:13
Hi there! I'm curious what the difference between using PipeTo and RecieveAsync. What approach is recommended now?
Aaron Stannard
@Aaronontheweb
Mar 21 2018 17:13
and waits for those actors to die
Onur Gumus
@OnurGumus
Mar 21 2018 17:13
yes I have did one. I am basically incrementing a count per actor when ever it receives a message and decrement when it asks for passivation and when the count is 0 parent kills the child
and child requests passivation after processing each message
so if there is any pending message the parent will keep that child alive
it's not like time based as on the sharding.
Jack Wild
@jackowild
Mar 21 2018 17:16
@Aaronontheweb yes please, there's a comment on there waiting for your reply :)
Onur Gumus
@OnurGumus
Mar 21 2018 17:16
in other words, these kind of things should not depend on clustering but be generic
managerger
@managerger
Mar 21 2018 17:19
Does it make sense to use PipeTo(Self) with non-generic Task?
Onur Gumus
@OnurGumus
Mar 21 2018 17:19
No
@managerger you can always project the tasks result to something by using ContinueWith
then pipe it
managerger
@managerger
Mar 21 2018 17:25
@OnurGumus Well, but I have simple asynchronous function call inside an actor, that returns nothing meaningful but non-generic task itself. The problem is that if I use ReceiveAsync, my actor waits the ending of asyn call and only than proceed with another message.
private async Task HandleCreatePerson(CreateUsert createUser)
    {
        using (AsyncScopedLifestyle.BeginScope(_container))
        {
            await _commandBus.Send(createUser);
        }
    }
Onur Gumus
@OnurGumus
Mar 21 2018 17:27
just call this task as if it is sync and forget about it then.
managerger
@managerger
Mar 21 2018 17:28
@OnurGumus Sounds reasonable! Thanks, mate
v1rusw0rm
@v1rusw0rm
Mar 21 2018 17:55
This message was deleted
Havret
@Havret
Mar 21 2018 20:34
@Aaronontheweb what did you mean by "the idea here, I assume
is to be able to CREATE the entities via DPS"