Repository navigation
Open
Labels
bugSomething isn't working
Description
Summary
Two wallet unit tests fail intermittently because the P2MR keypool is already refilled where the test expects the size before the refill ([32 != 16]). Both assert that a scheduled refill has not run yet while a CScheduler timer that counts real time is pending.
Observed
1. wallet_p2mr_deferred_keypool_tests/StartWalletsSchedulesDeferredP2MRKeypoolTopUpForStartupWallets
wallet/test/wallet_p2mr_deferred_keypool_tests.cpp(495): error: check spk_man->GetKeyPoolSize() == expected has failed [32 != 16]
- Jobs
130034859213("ASan + LSan + UBSan + integer") and130034859238("TSan, depends, no gui"), push run atbdc43f3e08, 2026-11-10. - The failing check is the one after
scheduler.MockForward(std::chrono::seconds{25})(line 552).m_wallet_loader->start(scheduler)schedules the deferred top-up 30 s out in real time, andMockForward(25s)moves it 25 s earlier. The check is therefore only valid if less than 5 s of real time passes betweenstart()and the check. - In the ASan log the wallets finished loading at 02:28:51.17, and the
RemoveWallet/WaitForDeleteWalletthat the test runs beforeMockForwarddid not finish until 02:29:00.52, about 9 s later. The top-up started at once ("completed in 43503ms" at 02:29:44.23) and the check saw 32 keys.
2. wallet_p2mr_receive_keypool_tests/P2MRGetNewAddressSchedulesLowWatermarkRefill
wallet/test/wallet_p2mr_receive_keypool_tests.cpp(81): error: check external_spk_man->GetKeyPoolSize() == low_watermark has failed [32 != 16]
wallet/test/wallet_p2mr_receive_keypool_tests.cpp(84): error: check external_spk_man->GetWalletDescriptor().range_end == range_end_at_watermark has failed [48 != 32]
- Job
131257866339("TSan, depends, no gui"), push run at1efb3ae344, 2026-11-12. MaybeScheduleP2MRKeyPoolRefillschedules the refill 1 ms out (src/wallet/wallet.cpp:535). The test then reads the pool size without holdingcs_wallet, so it races the scheduler thread.- The log shows the scheduler thread winning:
15:08:05.976506Z [test] P2MR receive keypool reached low-watermark; scheduling background refill (... remaining=16, low_watermark=16)
15:08:05.981958Z [test] [lock] Enter: lock contention cs_desc_man, wallet/scriptpubkeyman.cpp:2128 started
15:08:08.592072Z [test] [lock] Enter: lock contention cs_desc_man, wallet/scriptpubkeyman.cpp:2128 completed (2610033μs)
15:08:08.592489Z [scheduler] P2MR receive keypool background refill completed in 2613ms
Same pattern, not seen failing yet
wallet_p2mr_change_keypool_tests.cpp:196: pool size read right afterMaybeScheduleP2MRKeyPoolRefill, as in case 2.wallet_p2mr_deferred_keypool_tests.cpp:380and:453:MockForward(29s)against the 30 s delay, which leaves 1 s of real time.
Impact
Required sanitizer jobs go red on unrelated changes. Three failed jobs so far. WalletPassphraseSchedulesP2MRKeypoolRefill, which #411 replaced, failed in seven PR jobs before that: four on a !wallet->m_p2mr_receive_keypool_refill_scheduled check and three on test timeouts.
Suggested fix
Test-only:
- For the 1 ms refill, hold
cs_walletacross the scheduling call and the "not yet" checks, since the refill step needs that lock, or assert on the scheduled flag instead of the pool size. - For the 30 s top-up, assert "not yet" only when a steady-clock reading taken before scheduling shows the timer cannot be due, or drop that assertion.
Found while triaging failed CI jobs on 1.x.x (2026-11-13). Code references are to 1.x.x at a7a70660ad.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
ci: skip Full Validation and Core Checks for a tree that already passed
test: remove real-time dependence from P2MR keypool scheduler tests
ci: skip Full Validation and Core Checks for a tree that already pass…
test: remove real-time dependence from P2MR keypool scheduler tests
test: remove real-time dependence from P2MR keypool scheduler tests (#…