11

I recently experienced a I/O error resulting in data block corruption or index corruption cause bitcoin-qt wasn't quitting so I forced bitcoin core to shutdown without killin it properly. I checked the harddisk.. when I restarted Bitcoin-qt it asked me a question:

Error opening block database. Do you want to rebuild the block database now?

Answered yes but when Bitcoin core came up I realized that I was 4 years back to synchronize with the blockchain. So I immediately stopped it again to look for more information before proceeding for safety

I found the relevant command in bitcoin-core options to rebuild chain state:

bitcoin-qt -reindex
bitcoin-qt -reindex-chainstate

Edit : This useful answer from user Pieter Wuille here:
When should I use -reindex-chainstate and when -reindex answers my second question.

-reindex:

wipes the chainstate (the UTXO set)
wipes the block index (the database with information about which block is where on disk)
rebuilds the block index (by going over all blk*.dat files, and finding things in it that look like blocks)
rebuilds the chainstate (redoing all validation for blocks) based on the blocks now in the index

-reindex-chainstate:

wipes the chainstate
rebuilds the chainstate using the blocks in the index you had before


Found this bitcoin.se answer Bitcoind --reindex vs starting allover again but made me a bit uncertain on what to do next in order to retrieve my database without downloading the whole blockchain from the start

What would be the proper and fastest possible ways to rebuild/recheck my blockchain from Bitcoin-qt?

What is the difference of use between of bitcoin-qt -reindex vs bitcoin-qt -reindex-chainstate?

1 Answer 1

3

From: When should I use -reindex-chainstate and when -reindex

-reindex:

wipes the chainstate (the UTXO set) wipes the block index (the database with information about which block is where on disk) rebuilds the block index (by going over all blk*.dat files, and finding things in it that look like blocks) rebuilds the chainstate (redoing all validation for blocks) based on the blocks now in the index

-reindex-chainstate:

wipes the chainstate rebuilds the chainstate using the blocks in the index you had before The latter should be strictly faster, as it does not need to rebuild the block index first. Perhaps the progress bar during reindex confuses you: that progress is only for the rebuilding of the index. The recreation of the chainstate happens after that rebuild is completed.

You should use -reindex only when you were running in pruning mode, or if you suspect the blocks on disk are actually corrupted. Otherwise, when you only suspect corruption of the chainstate (which is far more likely), use -reindex-chainstate.

With -reindex I was able to restore my corrupted data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.