The wallet_reindex.py test has many issues:
- It uses a
assert_debug_logto ensure the reindex happened viainitload thread exit. However, no other test uses this pattern, becauserestart_nodealready achieves the same internally (viagetmempoolinfo.loaded). - The
assert_debug_logmay intermittently fail, because theinitload thread exitlog may happen at any time after the inner thread function (lambda) is fully done. - The test uses an
node.syncwithvalidationinterfacequeue()without any explanation. No other test uses this pattern, because all wallet RPCs, in particular the next one (gettransaction) call it internally (viaBlockUntilSyncedToCurrentChain).
Fix all issues by removing all confusing, useless, and brittle calls.
Example failure: https://github.com/bitcoin/bitcoin/actions/runs/22671604602/job/65716917459?pr=34419#step:11:22339
0...
1 node0 2026-03-04T13:55:23.784715Z (mocktime: 2026-03-04T22:15:17Z) [scheduler] [validationinterface.cpp:185] [operator()] [validation] UpdatedBlockTip: new block hash=24b5cc4c1352bc8841ecbe67a43827acd1adc609bd26b2691e80e89b97eff135 fork block hash=24a4dc8be9c157ac31913397d8bb1653900e12b55539c234039559fdeb6dd2fb (in IBD=true)
2 node0 2026-03-04T13:55:23.784851Z (mocktime: 2026-03-04T22:15:17Z) [initload] [util/thread.cpp:22] [TraceThread] initload thread exit
3 test 2026-03-04T13:55:23.813824Z TestFramework (ERROR): Unexpected exception:
4 Traceback (most recent call last):
5 File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_framework.py", line 142, in main
6 self.run_test()
7 File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 90, in run_test
8 self.birthtime_test(node, miner_wallet)
9 File "/home/admin/actions-runner/_work/_temp/build/test/functional/wallet_reindex.py", line 64, in birthtime_test
10 with node.assert_debug_log(expected_msgs=["initload thread exit"]):
11 File "/usr/lib/python3.12/contextlib.py", line 144, in __exit__
12 next(self.gen)
13 File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 607, in assert_debug_log
14 self._raise_assertion_error(f'Expected message(s) {remaining_expected!s} '
15 File "/home/admin/actions-runner/_work/_temp/test/functional/test_framework/test_node.py", line 241, in _raise_assertion_error
16 raise AssertionError(self._node_msg(msg))
17 AssertionError: [node 0] Expected message(s) ['initload thread exit'] not found in log:
Diff to reproduce failure:
0diff --git a/src/util/thread.cpp b/src/util/thread.cpp
1index 0fde73c4e2..de4c05e752 100644
2--- a/src/util/thread.cpp
3+++ b/src/util/thread.cpp
4@@ -8,2 +8,3 @@
5 #include <util/log.h>
6+#include <util/time.h>
7 #include <util/threadnames.h>
8@@ -21,2 +22,3 @@ void util::TraceThread(std::string_view thread_name, std::function<void()> threa
9 thread_func();
10+ UninterruptibleSleep(999ms);
11 LogInfo("%s thread exit", thread_name);
12diff --git a/test/functional/wallet_reindex.py b/test/functional/wallet_reindex.py
13index 71ab69e01b..649df4301a 100755
14--- a/test/functional/wallet_reindex.py
15+++ b/test/functional/wallet_reindex.py
16@@ -62,2 +62,3 @@ class WalletReindexTest(BitcoinTestFramework):
17
18+ import time; time.sleep(1) # Wait for previous initload thread to exit fully
19 # Reindex and wait for it to finish
Before on master: Test fails After on this pull: Test passes