From d7a80788cb4819dea57b2e7c16dbc6c46bb80985 Mon Sep 17 00:00:00 2001 From: pasta Date: Mon, 16 Nov 2026 00:39:07 -0600 Subject: [PATCH] test: drain LowerLastFlushedBlock's notifications before the next index starts LowerLastFlushedBlock() reorgs the chain (invalidate, flush, reconnect) and returned with up to ten of the reorg's validation notifications still queued: InvalidateBlock() and ActivateBestChain() only drain the queue once it holds more than ten callbacks. The notifications are delivered to whatever is registered when the scheduler gets to them, so with a loaded scheduler thread they could reach the index that the test starts next. That index is already synced to the tip, so a stale BlockConnected for a block it has indexed looks like a reorg: it rewinds to the block's parent and moves its committed locator down. In restart_after_rewind_reindexes_erased_blocks, that broke the check that the restarted index's committed tip is still 100, and the one after the rewind to 97. Wait for the notifications in the helper, while no index is registered. Co-Authored-By: Claude Opus 5.5 --- src/test/baseindex_tests.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/baseindex_tests.cpp b/src/test/baseindex_tests.cpp index 68c1d63a7704..4fafb9a9d563 100644 --- a/src/test/baseindex_tests.cpp +++ b/src/test/baseindex_tests.cpp @@ -106,6 +106,9 @@ void LowerLastFlushedBlock(ChainstateManager& chainman, int height) WITH_LOCK(::cs_main, chainstate.ResetBlockFailureFlags(first_disconnected)); BOOST_REQUIRE(chainstate.ActivateBestChain(state)); BOOST_REQUIRE_EQUAL(WITH_LOCK(::cs_main, return chainstate.GetLastFlushedBlock()->nHeight), height); + // Deliver the reorg's notifications now. Left in the queue, they would reach the next index to start, which would + // take the reconnects of blocks it already indexed as a reorg and rewind. + SyncWithValidationInterfaceQueue(); } } // namespace