-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix NeoSystem shutdown order #2842
Conversation
Due to my test, some issues still exist.
mainnet seed node
I will take a look at StatesDumper plugin while I finished resyncing full data of mainnet. In previous version, it will surely lose data after being interupted by |
I've not encountered this shutdown error myself, but somebody else inside coz has so we'll need to investigate further. |
It seems like plugins cannot call public void Dispose()
{
EnsureStopped(LocalNode);
// Dispose will call ActorSystem.Terminate()
ActorSystem.Dispose();
ActorSystem.WhenTerminated.Wait();
foreach (var p in Plugin.Plugins) <- TooLate
p.Dispose();
HeaderCache.Dispose();
store.Dispose();
} Moving it up like shown next resolves that exception. public void Dispose()
{
EnsureStopped(LocalNode);
// Dispose will call ActorSystem.Terminate()
foreach (var p in Plugin.Plugins) <- OK
p.Dispose();
ActorSystem.Dispose();
ActorSystem.WhenTerminated.Wait();
HeaderCache.Dispose();
store.Dispose();
} but then blocks still get persisted e.g.
I can fix this by adding an public void Dispose()
{
EnsureStopped(LocalNode);
EnsureStopped(Blockchain);
// Dispose will call ActorSystem.Terminate()
ActorSystem.Dispose();
ActorSystem.WhenTerminated.Wait();
foreach (var p in Plugin.Plugins)
p.Dispose();
HeaderCache.Dispose();
store.Dispose();
} to get
Now I still have to fix the exception that this causes when syncing from an offline chain. |
@superboyiii this should be it. The exception during offline chain sync I was seeing was due some change I did to the offline syncing system and does not apply to the default system. Can you help test this please? :) |
Sure. I'm doing that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ixje Nice fix! The exception and the inconsistent StateService issue has gone. For StatesDumper, I think it's another issue.
For StatesDumper, I think the issue comes from neo-project/neo-modules#568 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good fix @ixje
Thanks. This fixed my problem, too. #2624 |
fix neo-project/neo-modules#786
What I theorize is happening is that while the plugins are disposed (and they remove their
Committing
/Committed
handlers) in the background the main persist loop continues to add blocks and transactions. The plugins (like app log) no longer process these blocks hence we lose data. By first shutting down the "main loop" we ensure plugins don't miss anything.