The -reindex
option is broken on both the master branch and the 29.x branch (I have not tested older release branches).
Consider the following workflow on OpenBSD 7.7:
0$ rm -rf /home/hebasto/.bitcoin/regtest
1$ ./build/bin/bitcoind -regtest -daemon
2Bitcoin Core starting
3$ ./build/bin/bitcoin-cli -regtest createwallet $(date +%Y-%m-%d)
4$ ./build/bin/bitcoin-cli -regtest -generate 200
5$ ./build/bin/bitcoin-cli -regtest getblockcount
6200
7$ ./build/bin/bitcoin-cli -regtest stop
8Bitcoin Core stopping
9$ rm -rf /home/hebasto/.bitcoin/regtest/blocks/index
10$ ./build/bin/bitcoind -regtest -daemon
11Bitcoin Core starting
12$ tail -6 /home/hebasto/.bitcoin/regtest/debug.log
132025-08-02T15:02:00Z : Error initializing block database.
14Please restart with -reindex or -reindex-chainstate to recover.
152025-08-02T15:02:00Z Shutdown: In progress...
162025-08-02T15:02:00Z scheduler thread exit
172025-08-02T15:02:00Z Flushed fee estimates to fee_estimates.dat.
182025-08-02T15:02:00Z Shutdown: done
19$ rm /home/hebasto/.bitcoin/regtest/debug.log
20$ ./build/bin/bitcoind -regtest -daemon -reindex
21Bitcoin Core starting
22$ ./build/bin/bitcoin-cli -regtest getblockcount
230
24$ cat /home/hebasto/.bitcoin/regtest/debug.log
25
26
27
28
29
302025-08-02T15:13:08Z Bitcoin Core version v29.99.0-75ed673193c5 (release build)
312025-08-02T15:13:08Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
322025-08-02T15:13:08Z Using RdSeed as an additional entropy source
332025-08-02T15:13:08Z Using RdRand as an additional entropy source
342025-08-02T15:13:08Z Default data directory /home/hebasto/.bitcoin
352025-08-02T15:13:08Z Using data directory /home/hebasto/.bitcoin/regtest
362025-08-02T15:13:08Z Config file: /home/hebasto/.bitcoin/bitcoin.conf (not found, skipping)
372025-08-02T15:13:08Z Command-line arg: daemon=""
382025-08-02T15:13:08Z Command-line arg: regtest=""
392025-08-02T15:13:08Z Command-line arg: reindex=""
402025-08-02T15:13:08Z Using at most 125 automatic connections (512 file descriptors available)
412025-08-02T15:13:08Z scheduler thread start
422025-08-02T15:13:08Z Binding RPC on address ::1 port 18443
432025-08-02T15:13:08Z Binding RPC on address 127.0.0.1 port 18443
442025-08-02T15:13:08Z Generated RPC authentication cookie /home/hebasto/.bitcoin/regtest/.cookie
452025-08-02T15:13:08Z Permissions used for cookie: rw-------
462025-08-02T15:13:08Z Using random cookie authentication.
472025-08-02T15:13:08Z Starting HTTP server with 16 worker threads
482025-08-02T15:13:08Z Using wallet directory /home/hebasto/.bitcoin/regtest/wallets
492025-08-02T15:13:08Z init message: Verifying wallet(s)…
502025-08-02T15:13:08Z Using /16 prefix for IP bucketing
512025-08-02T15:13:08Z init message: Loading P2P addresses…
522025-08-02T15:13:08Z Loaded 0 addresses from peers.dat 0ms
532025-08-02T15:13:08Z init message: Loading banlist…
542025-08-02T15:13:08Z SetNetworkActive: true
552025-08-02T15:13:08Z Cache configuration:
562025-08-02T15:13:08Z * Using 2.0 MiB for block index database
572025-08-02T15:13:08Z * Using 8.0 MiB for chain state database
582025-08-02T15:13:08Z * Using 440.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
592025-08-02T15:13:08Z Script verification uses 7 additional threads
602025-08-02T15:13:08Z Using obfuscation key for blocksdir *.dat files (/home/hebasto/.bitcoin/regtest/blocks): '997651b2ed068218'
612025-08-02T15:13:08Z Wiping LevelDB in /home/hebasto/.bitcoin/regtest/blocks/index
622025-08-02T15:13:08Z Opening LevelDB in /home/hebasto/.bitcoin/regtest/blocks/index
632025-08-02T15:13:08Z Opened LevelDB successfully
642025-08-02T15:13:08Z Using obfuscation key for /home/hebasto/.bitcoin/regtest/blocks/index: 0000000000000000
652025-08-02T15:13:08Z Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
662025-08-02T15:13:08Z Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
672025-08-02T15:13:08Z init message: Loading block index…
682025-08-02T15:13:08Z Validating signatures for all blocks.
692025-08-02T15:13:08Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000000000000
702025-08-02T15:13:08Z Initializing chainstate Chainstate [ibd] @ height -1 (null)
712025-08-02T15:13:08Z Wiping LevelDB in /home/hebasto/.bitcoin/regtest/chainstate
722025-08-02T15:13:08Z Opening LevelDB in /home/hebasto/.bitcoin/regtest/chainstate
732025-08-02T15:13:08Z Opened LevelDB successfully
742025-08-02T15:13:08Z Wrote new obfuscation key for /home/hebasto/.bitcoin/regtest/chainstate: cc8a83834d10b91a
752025-08-02T15:13:08Z Using obfuscation key for /home/hebasto/.bitcoin/regtest/chainstate: cc8a83834d10b91a
762025-08-02T15:13:08Z init message: Verifying blocks…
772025-08-02T15:13:08Z Block index and chainstate loaded
782025-08-02T15:13:08Z Setting NODE_NETWORK on non-prune mode
792025-08-02T15:13:08Z initload thread start
802025-08-02T15:13:08Z Reindexing block file blk00000.dat...
812025-08-02T15:13:08Z UpdateTip: new best=0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206 height=0 version=0x00000001 log2_work=1.000000 tx=1 date='2011-02-02T23:16:42Z' progress=0.000002 cache=0.3MiB(0txo)
822025-08-02T15:13:08Z block tree size = 1
832025-08-02T15:13:08Z nBestHeight = 0
842025-08-02T15:13:08Z mapport thread start
852025-08-02T15:13:08Z torcontrol thread start
862025-08-02T15:13:08Z Bound to 127.0.0.1:18445
872025-08-02T15:13:08Z Bound to [::]:18444
882025-08-02T15:13:08Z Bound to 0.0.0.0:18444
892025-08-02T15:13:08Z Loaded 0 addresses from "anchors.dat"
902025-08-02T15:13:08Z 0 block-relay-only anchors will be tried for connections.
912025-08-02T15:13:08Z init message: Starting network threads…
922025-08-02T15:13:08Z net thread start
932025-08-02T15:13:08Z dnsseed thread start
942025-08-02T15:13:08Z Loading addresses from DNS seed dummySeed.invalid.
952025-08-02T15:13:08Z addcon thread start
962025-08-02T15:13:08Z opencon thread start
972025-08-02T15:13:08Z init message: Done loading
982025-08-02T15:13:08Z msghand thread start
992025-08-02T15:13:08Z 0 addresses found from DNS seeds
1002025-08-02T15:13:08Z dnsseed thread exit
1012025-08-02T15:13:08Z Loaded 1 blocks from external file in 38ms
1022025-08-02T15:13:08Z Reindexing finished
1032025-08-02T15:13:08Z Loading 0 mempool transactions from file...
1042025-08-02T15:13:08Z Imported mempool transactions from file: 0 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
1052025-08-02T15:13:08Z initload thread exit
106$ ./build/bin/bitcoin-cli -regtest stop
107Bitcoin Core stopping
Despite the log containing the messages “Reindexing block file blk00000.dat…” and “Reindexing finished”, the getblockcount
RPC returns 0.
It appears this issue affects other operating systems as well, as noted in #32987 (review).