Support for safely shutting down the NeoSystem#574
Conversation
NeoSystem
|
https://getakka.net/articles/actors/coordinated-shutdown.html Can we just use the "Coordinated Shutdown" for safely shutting down the |
|
Looks like it is available in the core parts of Akka. I'll work on switching this to use |
|
@erikzhang The solution is clean now and uses |
|
Sounds good to me, Jeff. |
@vncoelho It's working fine from my testing, can you give more details about the error you are getting? |
|
I did not get errors, I did not have time to check yet. I was mentioning about the possibility of a Unit Test. |
Well, there is certainly the possibility, and it would be nice to improve unit test coverage for the I've done manual integration testing of these changes with neo-cli. |
|
That is it, maybe following this template: neo/neo.UnitTests/UT_Consensus.cs Line 28 in bbbc0cf neo/neo.UnitTests/UT_Consensus.cs Line 125 in bbbc0cf We can create and initialize the actors and, then, kill/stop it. |
… the ActorSystem.
|
@erikzhang I made changes to the PR so it no longer waits for the |
|
Should be good now, just needs a bit of testing. |
|
I think stopping an actor and waiting for it to complete can be done with https://getakka.net/articles/actors/receive-actor-api.html#graceful-stop
|
|
@erikzhang that would require it processing all the messages in the queue to get to the message that stops it gracefully, which you said you didn't want to do earlier. If we want to throw the current messages in the actor queues away, then that doesn't work for us. |
| protected override void OnReceive(object message) | ||
| { | ||
| if (message is Terminated t && ActorSemaphores.TryGetValue(t.ActorRef, out SemaphoreSlim semWait)) | ||
| semWait.Release(short.MaxValue); |
There was a problem hiding this comment.
We could probably call Context.Unwatch(t.ActorRef) here also, but perhaps it doesn't matter since we are shutting down anyway.
We need to ensure the actors fully stop in the right order disposing the
ActorSystem. This change usesCoordinatedShutdownand registers a tasks to wait for theLocalNodeandBlockchainto actually stop before continuing with shutdown.Fixes #570