Skip to content

Commit bd17983

Browse files
committed
bookkeeper: fix assert() which happens with parallel queries.
``` bookkeeper: plugins/bkpr/bookkeeper.c:1226: parse_and_log_chain_move: Assertion `e->db_id > bkpr->chainmoves_index' failed. bookkeeper: FATAL SIGNAL 6 (version v25.09-245-g901714b-modded) 0x5d7d8718b40f send_backtrace common/daemon.c:36 0x5d7d8718b4ab crashdump common/daemon.c:81 0x7a6086c4532f ??? ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x7a6086c9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44 0x7a6086c9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78 0x7a6086c9eb2c __GI___pthread_kill ./nptl/pthread_kill.c:89 0x7a6086c4527d __GI_raise ../sysdeps/posix/raise.c:26 0x7a6086c288fe __GI_abort ./stdlib/abort.c:79 0x7a6086c2881a __assert_fail_base ./assert/assert.c:96 0x7a6086c3b516 __assert_fail ./assert/assert.c:105 0x5d7d8717505d parse_and_log_chain_move plugins/bkpr/bookkeeper.c:1226 0x5d7d871754f4 listchainmoves_done plugins/bkpr/bookkeeper.c:169 0x5d7d87182a4b handle_rpc_reply plugins/libplugin.c:1072 0x5d7d87182b5c rpc_conn_read_response plugins/libplugin.c:1361 0x5d7d871ba660 next_plan ccan/ccan/io/io.c:60 0x5d7d871bab31 do_plan ccan/ccan/io/io.c:422 0x5d7d871babee io_ready ccan/ccan/io/io.c:439 ``` Reported-by: @michael1011 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Changelog-Fixed: plugins: assertion crash in bookkeeper when fresh records arrive while multiple queries in progress.
1 parent c386995 commit bd17983

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

plugins/bkpr/bookkeeper.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,8 +1222,10 @@ parse_and_log_chain_move(struct command *cmd,
12221222
if (e->origin_acct)
12231223
find_or_create_account(cmd, bkpr, e->origin_acct);
12241224

1225-
/* Make this visible for queries (we expect increasing!) */
1226-
assert(e->db_id > bkpr->chainmoves_index);
1225+
/* Make this visible for queries (we expect increasing!). If we raced, this is not true. */
1226+
if (e->db_id <= bkpr->chainmoves_index)
1227+
return;
1228+
12271229
bkpr->chainmoves_index = e->db_id;
12281230

12291231
/* This event *might* have implications for account;
@@ -1336,8 +1338,9 @@ parse_and_log_channel_move(struct command *cmd,
13361338
" but no account exists %s",
13371339
acct_name);
13381340

1339-
/* Make this visible for queries (we expect increasing!) */
1340-
assert(e->db_id > bkpr->channelmoves_index);
1341+
/* Make this visible for queries (we expect increasing!). If we raced, this is not true. */
1342+
if (e->db_id <= bkpr->channelmoves_index)
1343+
return;
13411344
bkpr->channelmoves_index = e->db_id;
13421345

13431346
/* Check for invoice desc data, necessary */

tests/test_bookkeeper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,6 @@ def test_listincome_timebox(node_factory, bitcoind):
11951195
assert [i for i in incomes if i['timestamp'] > first_one] == []
11961196

11971197

1198-
@pytest.mark.xfail(strict=True)
11991198
@unittest.skipIf(TEST_NETWORK != 'regtest', "Snapshots are bitcoin regtest.")
12001199
@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "uses snapshots")
12011200
def test_bkpr_parallel(node_factory, bitcoind, executor):

0 commit comments

Comments
 (0)