Skip to content

Commit 626998e

Browse files
rustyrussellcdecker
authored andcommitted
lightningd: don't timeout plugins if init is slow!
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 <[email protected]>
1 parent 3d311c9 commit 626998e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lightningd/plugin.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ static void check_plugins_initted(struct plugins *plugins)
180180
for (size_t i = 0; i < tal_count(plugin_cmds); i++)
181181
plugin_cmd_all_complete(plugins, plugin_cmds[i]);
182182
tal_free(plugin_cmds);
183+
184+
if (plugins->startup)
185+
io_break(plugins);
183186
}
184187

185188
struct command_result *plugin_register_all_complete(struct lightningd *ld,
@@ -1943,6 +1946,11 @@ void plugins_config(struct plugins *plugins)
19431946
plugin_config(p);
19441947
}
19451948

1949+
/* Wait for them to configure, before continuing: large
1950+
* nodes can take a while to startup! */
1951+
if (plugins->startup)
1952+
io_loop_with_timers(plugins->ld);
1953+
19461954
plugins->startup = false;
19471955
}
19481956

tests/test_plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,8 @@ def test_plugin_fail(node_factory):
19421942
time.sleep(2)
19431943
# It should clean up!
19441944
assert 'failcmd' not in [h['command'] for h in l1.rpc.help()['help']]
1945+
# Can happen *before* the 'Server started with public key'
1946+
l1.daemon.logsearch_start = 0
19451947
l1.daemon.wait_for_log(r': exited during normal operation')
19461948

19471949
l1.rpc.plugin_start(plugin)

0 commit comments

Comments
 (0)