Skip to content

Intermittent issue in feature_assumeutxo.py", line 629, in run_test assert not self.has_blockfile(n1, "00002"), "too many blockfiles" #33635

Closed

Description

@maflcko

Seen locally in https://drahtbot.space/temp_scratch/feature_assumeutxo_265.tar.zstd:

commit should be roughly 40e7d4c and the command was RUN_UNIT_TESTS=false MAKEJOBS="-j8" FILE_ENV="./ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh" ./ci/test_run_all.sh

 node1 2025-10-15T18:56:48.763939Z [shutoff] [txdb.cpp:151] [virtual bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor &, const uint256 &)] [coindb] Writing final batch of 0.00 MiB 
 node1 2025-10-15T18:56:48.763948Z [shutoff] [txdb.cpp:153] [virtual bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor &, const uint256 &)] [coindb] Committed 0 changed transaction outputs (out of 0) to coin database... 
 node1 2025-10-15T18:56:48.763958Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write coins cache to disk (0 coins, 256KiB) completed (0.02ms) 
 node1 2025-10-15T18:56:48.763966Z [shutoff] [validationinterface.cpp:246] [void ValidationSignals::ChainStateFlushed(ChainstateRole, const CBlockLocator &)] [validation] Enqueuing ChainStateFlushed: block hash=5d3144f90878dbabd3a42352be3294df923c93198e1399b93d07292c9cd1e1ce 
 node1 2025-10-15T18:56:48.763997Z [shutoff] [validation.cpp:2837] [bool Chainstate::FlushStateToDisk(BlockValidationState &, FlushStateMode, int)] [coindb] Writing chainstate to disk: flush mode=ALWAYS, prune=0, large=0, critical=0, periodic=0 
 node1 2025-10-15T18:56:48.764007Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write block and undo data to disk started 
 node1 2025-10-15T18:56:48.764041Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write block and undo data to disk completed (0.03ms) 
 node1 2025-10-15T18:56:48.764050Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write block index to disk started 
 node1 2025-10-15T18:56:48.764061Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write block index to disk completed (0.01ms) 
 node1 2025-10-15T18:56:48.764067Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write coins cache to disk (0 coins, 256KiB) started 
 node1 2025-10-15T18:56:48.764076Z [shutoff] [txdb.cpp:151] [virtual bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor &, const uint256 &)] [coindb] Writing final batch of 0.00 MiB 
 node1 2025-10-15T18:56:48.764083Z [shutoff] [txdb.cpp:153] [virtual bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor &, const uint256 &)] [coindb] Committed 0 changed transaction outputs (out of 0) to coin database... 
 node1 2025-10-15T18:56:48.764092Z [shutoff] [logging/timer.h:58] [void BCLog::Timer<std::chrono::duration<long long, std::ratio<1, 1000>>>::Log(const std::string &) [TimeType = std::chrono::duration<long long, std::ratio<1, 1000>>]] [bench] FlushStateToDisk: write coins cache to disk (0 coins, 256KiB) completed (0.02ms) 
 node1 2025-10-15T18:56:48.764100Z [shutoff] [validationinterface.cpp:246] [void ValidationSignals::ChainStateFlushed(ChainstateRole, const CBlockLocator &)] [validation] Enqueuing ChainStateFlushed: block hash=6d9186a0db6df121d2006c40c7827c447afe6329b705666bca1744b72c71f0ad 
 node1 2025-10-15T18:56:48.767027Z [shutoff] [init.cpp:410] [void Shutdown(NodeContext &)] Shutdown done 
 test  2025-10-15T18:56:48.791717Z TestFramework.node1 (DEBUG): Node stopped 
 test  2025-10-15T18:56:48.791816Z TestFramework (INFO): Checking that blocks are segmented on disk 
 test  2025-10-15T18:56:48.791990Z TestFramework (ERROR): Unexpected exception 
                                   Traceback (most recent call last):
                                     File "/ci_container_base/test/functional/test_framework/test_framework.py", line 198, in main
                                       self.run_test()
                                     File "/ci_container_base/ci/scratch/build-x86_64-pc-linux-gnu/test/functional/feature_assumeutxo.py", line 629, in run_test
                                       assert not self.has_blockfile(n1, "00002"), "too many blockfiles"
                                   AssertionError: too many blockfiles

Activity

  1. b-l-u-e commented on Jan 26, 2026

    @b-l-u-e
    Contributor

    Seen locally in https://drahtbot.space/temp_scratch/feature_assumeutxo_265.tar.zstd:

    i tried studying from the report shared above realized that maybe the assertion assert not self.has_blockfile(n1, "00002") was too strict perhaps maybe we can condition it because segmentation works as expected

    coz with -fastprune it does 64KB blockfiles... coz node1 runs two chainstates concurrently NORMAL and ASSUMED...so this segmentation keeps their blocks separate

    so when NORMAL syncs enough blocks to fill blk00000.dat it creates blk00002.dat

    from node1/regtest/debug.log

    [assumed] initializing blockfile cursor to BlockfileCursor(file_num=1)
    ...
    Leaving block file 0: CBlockFileInfo(blocks=242, size=65331, heights=0...240) (onto 2) (height 241)
    

    i think or rather maybe test should verify segmentation works blk00001.dat exists for ASSUMED blocks not just limit to 2 files

  2. maflcko commented on Jan 27, 2026

    @maflcko
    MemberAuthor

    I think this is -stopatheight not working?

  3. maflcko commented on Jan 27, 2026

    @maflcko
    MemberAuthor

    Hmmm, maybe not, because this diff is passing:

    diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
    index 20ebd823d1..959b3bbd9a 100755
    --- a/test/functional/feature_assumeutxo.py
    +++ b/test/functional/feature_assumeutxo.py
    @@ -606,7 +606,7 @@ class AssumeutxoTest(BitcoinTestFramework):
             assert signed_txid in n1.getrawmempool()
             assert not n1.gettxout(prev_tx['txid'], 0)
     
    -        PAUSE_HEIGHT = FINAL_HEIGHT - 40
    +        PAUSE_HEIGHT = FINAL_HEIGHT 
     
             self.log.info("Restarting node to stop at height %d", PAUSE_HEIGHT)
             self.restart_node(1, extra_args=[
  4. maflcko commented on Jan 29, 2026

    @maflcko
    MemberAuthor

    I tried to reproduce this with the command below, but failed. I guess this fixed itself?

    while ( TEST_RUNNER_EXTRA="$( for i in {1..400}; do echo -n "feature_assumeutxo.py "; done )" RUN_UNIT_TESTS=false MAKEJOBS="-j8" FILE_ENV="./ci/test/00_setup_env_native_nowallet.sh" ./ci/test_run_all.sh ) ; do echo _ >> /tmp/runs ; done

  5. maflcko commented on Jan 29, 2026

    @maflcko
    MemberAuthor
  6. maflcko commented on Jan 30, 2026

    @maflcko
    MemberAuthor

    i tried studying from the report shared above realized that maybe the assertion assert not self.has_blockfile(n1, "00002") was too strict perhaps maybe we can condition it because segmentation works as expected

    coz with -fastprune it does 64KB blockfiles... coz node1 runs two chainstates concurrently NORMAL and ASSUMED...so this segmentation keeps their blocks separate

    so when NORMAL syncs enough blocks to fill blk00000.dat it creates blk00002.dat

    from node1/regtest/debug.log

    [assumed] initializing blockfile cursor to BlockfileCursor(file_num=1)
    ...
    Leaving block file 0: CBlockFileInfo(blocks=242, size=65331, heights=0...240) (onto 2) (height 241)
    

    Thanks for taking a look. I am primarily interested in why this is happening intermittently. Usually this happens due to one thread being slower than another. For example in #34425, a sleep added in the right place will make a particular intermittent issue appear more deterministically:

    diff --git a/src/net.cpp b/src/net.cpp
    index 6b79e913e8..32bd061500 100644
    --- a/src/net.cpp
    +++ b/src/net.cpp
    @@ -2200,2 +2200,3 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
                     }
    +            UninterruptibleSleep(599ms);
                     pnode->CloseSocketDisconnect();
    

    I'd be great to find a diff to make this one reproduce deterministically as well.

  7. b-l-u-e commented on Jan 30, 2026

    @b-l-u-e
    Contributor

    i tried studying from the report shared above realized that maybe the assertion assert not self.has_blockfile(n1, "00002") was too strict perhaps maybe we can condition it because segmentation works as expected
    coz with -fastprune it does 64KB blockfiles... coz node1 runs two chainstates concurrently NORMAL and ASSUMED...so this segmentation keeps their blocks separate
    so when NORMAL syncs enough blocks to fill blk00000.dat it creates blk00002.dat
    from node1/regtest/debug.log

    [assumed] initializing blockfile cursor to BlockfileCursor(file_num=1)
    ...
    Leaving block file 0: CBlockFileInfo(blocks=242, size=65331, heights=0...240) (onto 2) (height 241)
    

    Thanks for taking a look. I am primarily interested in why this is happening intermittently. Usually this happens due to one thread being slower than another. For example in #34425, a sleep added in the right place will make a particular intermittent issue appear more deterministically:

    diff --git a/src/net.cpp b/src/net.cpp
    index 6b79e913e8..32bd061500 100644
    --- a/src/net.cpp
    +++ b/src/net.cpp
    @@ -2200,2 +2200,3 @@ void CConnman::SocketHandlerConnected(const std::vector<CNode*>& nodes,
                     }
    +            UninterruptibleSleep(599ms);
                     pnode->CloseSocketDisconnect();
    

    I'd be great to find a diff to make this one reproduce deterministically as well.

    Let me try to add a sleep between when NORMAL and ASSUMED chainstates start the syncing

  8. b-l-u-e commented on Feb 3, 2026

    @b-l-u-e
    Contributor

    I'd be great to find a diff to make this one reproduce deterministically as well.

    so i did a test repro run by adding a sleep in ConnectTip() for the snapshot chainstate slows it down giving the normal chainstate time to fill blk00000.dat and roll to blk00002.dat before -stopatheight triggers

    diff --git a/src/validation.cpp b/src/validation.cpp
    --- a/src/validation.cpp
    +++ b/src/validation.cpp
    @@ -3079,6 +3079,10 @@ bool Chainstate::ConnectTip(...)
         {
             CCoinsViewCache& view{*m_coins_views->m_connect_block_view};
             const auto reset_guard{view.CreateResetGuard()};
    +        if (m_from_snapshot_blockhash) {
    +            UninterruptibleSleep(std::chrono::milliseconds{120});
    +        }
             bool rv = ConnectBlock(*block_to_connect, state, pindexNew, view);

    and also i made change infeature_assumeutxo.py with a 10s wait_until_stopped so as the slowed snapshot can reach -stopatheight).

    diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
    --- a/test/functional/feature_assumeutxo.py
    +++ b/test/functional/feature_assumeutxo.py
    @@ -644,15 +644,12 @@ class AssumeutxoTest(BitcoinTestFramework):
             # assertions and the -stopatheight tripping.
             self.connect_nodes(0, 1, wait_for_connect=False)
     
    -        n1.wait_until_stopped(timeout=5)
    +        n1.wait_until_stopped(timeout=10)  
     
             self.log.info("Checking that blocks are segmented on disk")
             assert self.has_blockfile(n1, "00000"), "normal blockfile missing"
             assert self.has_blockfile(n1, "00001"), "assumed blockfile missing"
             assert not self.has_blockfile(n1, "00002"), "too many blockfiles"
     
             self.log.info("Restarted node before snapshot validation completed, reloading...")
             self.restart_node(1, extra_args=self.extra_args[1])
    • and i run with --nocleanup --tmpdir=/tmp/bitcoin_test_assumeutxo_repro to see the results
    /tmp/bitcoin_test_assumeutxo_repro/node1/regtest/blocks/
    blk00000.dat  65331 bytes  (filled normal chainstate)
    blk00001.dat  32768 bytes  (snapshot chainstate)
    blk00002.dat  32768 bytes  (normal chainstate rollover)
    
    • so with -fastprune, blockfiles are 64 KiB
    • the sleep delays the snapshot chainstate from reaching -stopatheight=359
    • while also the background chainstate fills the 64 KiB blockfile
    • so when its full, it rolls to blk00002.dat since blk00001.dat is reserved for snapshot
  9. maflcko commented on Mar 18, 2026

    @maflcko
    MemberAuthor

    diff to reproduce:

    diff --git a/src/util/tokenpipe.cpp b/src/util/tokenpipe.cpp
    index c982fa6fc4..1dc12ea1d5 100644
    --- a/src/util/tokenpipe.cpp
    +++ b/src/util/tokenpipe.cpp
    @@ -4,2 +4,3 @@
     #include <util/tokenpipe.h>
    +#include <util/time.h>
     
    @@ -60,2 +61,3 @@ int TokenPipeEnd::TokenRead()
             ssize_t result = read(m_fd, &token, 1);
    +        UninterruptibleSleep(999ms);
             if (result < 0) {
  10. added a commit that references this issue on Mar 19, 2026
  11. added a commit that references this issue on Jun 28, 2026
  12. added a commit that references this issue on Jun 30, 2026
  13. added a commit that references this issue on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions