Skip to content

Commit

Permalink
lightningd: don't timeout plugins if init is slow!
Browse files Browse the repository at this point in the history
This is a minimal fix: we wait until all plugins reply from init before
continuing.  Really large or busy nodes can have other things monopolize
lightningd, then the timer goes off and we blame the plugin (which has
responded, we just haven't read it yet!).

The real answer is to have some timeouts only advance when we're idle,
or have them low-priority so we only activate them when we're idle (this
doesn't apply to all timers: some are probably important!).  But
this is a minimal fix for -rc3.

Fixes: #5736
Changelog-Fixed: plugins: on large/slow nodes we could blame plugins for failing to answer init in time, when we were just slow.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell authored and cdecker committed Nov 27, 2022
1 parent 3d311c9 commit 626998e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ static void check_plugins_initted(struct plugins *plugins)
for (size_t i = 0; i < tal_count(plugin_cmds); i++)
plugin_cmd_all_complete(plugins, plugin_cmds[i]);
tal_free(plugin_cmds);

if (plugins->startup)
io_break(plugins);
}

struct command_result *plugin_register_all_complete(struct lightningd *ld,
Expand Down Expand Up @@ -1943,6 +1946,11 @@ void plugins_config(struct plugins *plugins)
plugin_config(p);
}

/* Wait for them to configure, before continuing: large
* nodes can take a while to startup! */
if (plugins->startup)
io_loop_with_timers(plugins->ld);

plugins->startup = false;
}

Expand Down
2 changes: 2 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1942,6 +1942,8 @@ def test_plugin_fail(node_factory):
time.sleep(2)
# It should clean up!
assert 'failcmd' not in [h['command'] for h in l1.rpc.help()['help']]
# Can happen *before* the 'Server started with public key'
l1.daemon.logsearch_start = 0
l1.daemon.wait_for_log(r': exited during normal operation')

l1.rpc.plugin_start(plugin)
Expand Down

0 comments on commit 626998e

Please sign in to comment.