Skip to content

Commit 8732410

Browse files
committed
lightningd: print last method we called if we abort processing loop.
We are seeing this in the CI logs, eg tests/test_connection.py::test_reconnect_sender_add1: lightningd-1 2025-11-17T05:48:00.665Z DEBUG jsonrpc#84: Pausing parsing after 1 requests followed by: lightningd-1 2025-11-17T05:48:02.068Z **BROKEN** 022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d59-connectd: wake delay for WIRE_CHANNEL_REESTABLISH: 8512msec So, what is consuming lightningd for 8 or so seconds? This message helped diagnose that the issue was dev-memleak: fixed in a different branch. Signed-off-by: Rusty Russell <[email protected]>
1 parent 47ab467 commit 8732410

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lightningd/jsonrpc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,8 @@ REGISTER_PLUGIN_HOOK_STRFILTER(rpc_command,
10061006
static struct command_result *
10071007
parse_request(struct json_connection *jcon,
10081008
const char *buffer,
1009-
const jsmntok_t tok[])
1009+
const jsmntok_t tok[],
1010+
const char **methodname)
10101011
{
10111012
const jsmntok_t *method, *id, *params, *filter, *jsonrpc;
10121013
struct command *c;
@@ -1114,6 +1115,7 @@ parse_request(struct json_connection *jcon,
11141115
rpc_hook->custom_replace = NULL;
11151116
rpc_hook->custom_buffer = NULL;
11161117

1118+
*methodname = c->json_cmd->name;
11171119
trace_span_start("lightningd/jsonrpc", &c);
11181120
trace_span_tag(&c, "method", c->json_cmd->name);
11191121
/* They can filter by command name */
@@ -1183,6 +1185,7 @@ static struct io_plan *read_json(struct io_conn *conn,
11831185
const jsmntok_t *toks;
11841186
const char *buffer, *error;
11851187
size_t num_parsed = 0;
1188+
const char *last_method = NULL;
11861189

11871190
buffer = jsonrpc_newly_read(jcon->json_in, &len_read);
11881191
if (len_read)
@@ -1209,7 +1212,7 @@ static struct io_plan *read_json(struct io_conn *conn,
12091212
db_begin_transaction(jcon->ld->wallet->db);
12101213
in_transaction = true;
12111214
}
1212-
parse_request(jcon, buffer, toks);
1215+
parse_request(jcon, buffer, toks, &last_method);
12131216
jsonrpc_io_parse_done(jcon->json_in);
12141217

12151218
/* Don't ever process for more than 100 commands or 250 msec
@@ -1218,7 +1221,10 @@ static struct io_plan *read_json(struct io_conn *conn,
12181221
|| time_greater(timemono_between(time_mono(), start_time),
12191222
time_from_msec(250))) {
12201223
db_commit_transaction(jcon->ld->wallet->db);
1221-
log_debug(jcon->log, "Pausing parsing after %zu requests", num_parsed);
1224+
log_debug(jcon->log, "Pausing parsing after %zu requests and %"PRIu64"msec (last method=%s)",
1225+
num_parsed,
1226+
time_to_msec(timemono_between(time_mono(), start_time)),
1227+
last_method ? last_method : "NONE");
12221228
/* Call us back, as if we read nothing new */
12231229
return io_always(conn, read_json, jcon);
12241230
}

0 commit comments

Comments
 (0)