-
Notifications
You must be signed in to change notification settings - Fork 913
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
lightningd: shutdown plugins in two steps, db_write plugins as last #5872
lightningd: shutdown plugins in two steps, db_write plugins as last #5872
Conversation
28b6553
to
b066a2b
Compare
Weirdly the one failing (canceled) test log shows:
which is exactly the test added in 2cb93d4 to demonstrate the hang, but the test was disabled!
Before a rebasing/squash I will put some effort in understanding the new shutdown logic introduced in edit: if anything indicative, |
@endothermicdev should we consider this for |
…er closing db in second shutdown_plugin call, trigger EOF in plugin stdin. This correctly handles corner cases in shutdown_plugin: - in a non-dev build, buildin plugins don't subscribe shutdown, but we still need a (brief) io_loop to notify interested db_write plugins - only an awaited-for plugin should call io_break - allways send EOF to db_write plugins in the final call (subscribed or not) This adds two helper functions: plugin_registered_db_write_hook jsonrpc_command_del and a new plugin state: SHUTDOWN inspired by ElementsProject#4790 and also credit to ZmnSCPxj for mentioning the EOF idea in ElementsProject#4785
…allways receive an EOF they can still subscribe "shutdown", but we only wait for them after the EOF.
4e73b41
to
57e1c6f
Compare
Cleanup, rewording and added two asserts. Removed unnecessary sleeps and delays. I removed Note that a 1 millisecond timer is used when the Line 453 in f1373fd
and that all notifications are written out in one cycle. Then rebased and squashed. |
I got stuck translating into human language what is happening with (other) hooks during shutdown, as it doesn't seem defined very well, see #5859. I will close this while waiting for answers. |
Addresses issue #5859 to keep
db_write
-plugins alive when lightningd is shutting down, until after the database is closed.This revives an old idea (from #4790) to call
shutdown_plugins
twice:db_write
plugins to terminate.db_write
plugins can safely self-terminate when they see an EOF event at their stdin.Onetest_htlc_accepted_hook_shutdown
was added (currently skipped) to demonstrate a hang when L1 tries to pay an invoice while L2 is shutting down.Changed this into pull request after squashing, the unsquashed draft can be found here
TODO: