Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: decryptit on April 18, 2024, 06:59:38 PM



Title: Bitcoin Core v27.0 Error reading from database
Post by: decryptit on April 18, 2024, 06:59:38 PM
Hi all,

I am having issues with starting my Bitcoin Core wallet on a Windows. I keep getting error stating: Error reading from database.

I've tried to uninstall and reinstall different BC version, still the same error and the wallet won't start. It was previously fully synced.

At the bottom of the debug log, it shows LevelDB error: Corruption block checksum mismatch: F:\Bitcoin\chainstate/3348075.ldb.

From reading on a couple of other posts with similar problem, it looks like the recommendation was to save the wallet.dat and delete and restart everything.

My question is, is it possible to delete the 3348075.ldb from the chainstate folder and restart from there? Would that help minimize having to resync the entire blockchain again?

Thank you.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: achow101 on April 18, 2024, 07:18:34 PM
Starting with -reindex-chainstate should be good enough, you won't need to resync all of the blocks as the corruption is in the chainstate database and not the blockchain.

My question is, is it possible to delete the 3348075.ldb from the chainstate folder and restart from there? Would that help minimize having to resync the entire blockchain again?
No. LevelDB lays out its database in a particular way and deleting any of its files is a surefire way to have even more corruption. The data there is not necessarily stored sequentially.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: decryptit on April 18, 2024, 07:24:39 PM
How do I do the reindex-chainstate files?

Starting with -reindex-chainstate should be good enough, you won't need to resync all of the blocks as the corruption is in the chainstate database and not the blockchain.

My question is, is it possible to delete the 3348075.ldb from the chainstate folder and restart from there? Would that help minimize having to resync the entire blockchain again?
No. LevelDB lays out its database in a particular way and deleting any of its files is a surefire way to have even more corruption. The data there is not necessarily stored sequentially.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: promise444c5 on April 18, 2024, 11:05:21 PM
How do I do the reindex-chainstate files?
Inorder to perform reindex (https://bitcointalk.org/index.php?topic=5484601.0)
Navigate to your  bitcoin.conf  file , by default  located in 
C:\Users\<you>\AppData\Local\Bitcoin
Else, check the part selected while installing ,if you don't have it create one.
Insert
Code:
 reindex-chainstate=1


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: nc50lc on April 19, 2024, 04:55:00 AM
How do I do the reindex-chainstate files?
First, close Bitcoin Core.
Find Bitcoin Core's installation folder, look for "Bitcoin-qt" if you're using the GUI, else in daemon folder. (if you've used the installer, it defaults to "C:\Program Files\Bitcoin")
While inside that folder, click Windows Explorer's "File" menu and select "Open Windows PowerShell" that will select the current folder as your working directory.
The working directory should be displayed in PowerShell, e.g.: PS C:\Program Files\Bitcoin>

In PowerShell, enter this to start Bitcoin-qt with the mentioned command line arg:
Code:
./bitcoin-qt --reindex-chainstate
That'll start Bitcoin Core and tell it to rebuild the chainstate.
Take note that it will take quite some time but it will not re-download blocks that you already have, unless your blockchain is "pruned".


If you decided to follow the instructions above, you MUST remove that entry in your bitcoin.conf after your node is done with it.
Or else, it will reindex-chainstate every time you restart the client.

Also, the default data directory is in the "Roaming" appdata directory instead of "local".
So it should be in: C:\Users\<YOUR_USERNAME>\AppData\Roaming\Bitcoin ; Shortcut: %appdata%/bitcoin
But if you've set the datadir in F:/ with the GUI's "Welcome Screen", you should use/create the bitcoin.conf file there.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: satscraper on April 19, 2024, 07:03:36 AM

From reading on a couple of other posts with similar problem, it looks like the recommendation was to save the wallet.dat and delete and restart everything.


Probably to start from the  scratch is the best advice you have found so far as reindex-chainstate takes the painful time and doesn't guarantee that it will cope with the problem.

A few months ago I found myself in the similar situation and reindex-chainste didn't help thus I wasted the time trying to use it to avoid IBD.

When starting from scratch don't forget to put down into bitcoin.conf the following entries: dbcache=1/4 RAM  (for 8 GB  dbcache=2048, while for 16 GB dbcache=4096) and blocksonly=1 to sync a bit faster.

BTW, v. 27.0 completes its  halt operations much faster then my previous 26.0



Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: nc50lc on April 19, 2024, 07:14:55 AM
Probably to start from the  scratch is the best advice you have found so far as reindex-chainstate takes the painful time and doesn't guarantee that it will cope with the problem.
But the debug.log entry shows otherwise.
It specifically written that a file in his chainstate folder is corrupted that should be fixed by rebuilding the chainstate as mentioned by achow101.
Your previous case may not be related to chainstate corruption that's why the command didn't worked.

And the time it takes to --reindex-chainstate may not be fast but not as slow as --reindex or IBD.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: satscraper on April 19, 2024, 08:10:21 AM
And the time it takes to --reindex-chainstate may not be fast but not as slow as --reindex or IBD.

Agreed, but IBD secures full guarantee of pure untouched  copy of blockchain at your possession.

After my case I'm sold on the keeping of backup copy of the blockchain. I have acquired  2TB SSD and attach it to my node from time to time to keep this backup active.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: snerd on April 19, 2024, 08:21:33 PM
And the time it takes to --reindex-chainstate may not be fast but not as slow as --reindex or IBD.

Agreed, but IBD secures full guarantee of pure untouched  copy of blockchain at your possession.

After my case I'm sold on the keeping of backup copy of the blockchain. I have acquired  2TB SSD and attach it to my node from time to time to keep this backup active.
I set a folder backup to run once a day. Restoring will leave only one day to sync.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: decryptit on April 24, 2024, 03:15:14 AM
How do I do the reindex-chainstate files?
Inorder to perform reindex (https://bitcointalk.org/index.php?topic=5484601.0)
Navigate to your  bitcoin.conf  file , by default  located in 
C:\Users\<you>\AppData\Local\Bitcoin
Else, check the part selected while installing ,if you don't have it create one.
Insert
Code:
 reindex-chainstate=1


I see. Let me try this one. Thanks.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: decryptit on April 24, 2024, 03:42:45 AM
How do I do the reindex-chainstate files?
Inorder to perform reindex (https://bitcointalk.org/index.php?topic=5484601.0)
Navigate to your  bitcoin.conf  file , by default  located in 
C:\Users\<you>\AppData\Local\Bitcoin
Else, check the part selected while installing ,if you don't have it create one.
Insert
Code:
 reindex-chainstate=1


I see. Let me try this one. Thanks.

So I did the reindex-chainstate=1 and removed the pound sign. Now Bitcoin Core wallet is running again, but now it's starting back from 2009, which was the reason I was afraid I'd have to do.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: nc50lc on April 24, 2024, 04:11:14 AM
-snip-
So I did the reindex-chainstate=1 and removed the pound sign. Now Bitcoin Core wallet is running again, but now it's starting back from 2009, which was the reason I was afraid I'd have to do.
I made a note about reindex-chainstate in my reply just below his.
To rephrase that, if your blockchain is pruned, it'll have to redownload the blockchain to rebuild the chainstate.
If it is pruned, I'm afraid that you don't have any choice but to restart IBD due to having a corrupted chainstate and pruned blockchain.
Also, read the other important notes since you've used the config file method.

Or is your blockchain not pruned?
Because it will seemingly do IBD but it's just processing the existing blocks on your disk.
Are you using Bitcoin-qt (with GUI)? Does it show "Processing Blocks on disk", if so, that's just "reindexing"... not downloading.


Title: Re: Bitcoin Core v27.0 Error reading from database
Post by: promise444c5 on April 24, 2024, 06:48:32 PM

So I did the reindex-chainstate=1 and removed the pound sign. Now Bitcoin Core wallet is running again, but now it's starting back from 2009, which was the reason I was afraid I'd have to do.
Are you using a prune mode ?? Or you don't  know how to check ??
If yes (you don't know if it's  pruned )
For bitcoin-qtwith GUI go to your
settings>options
You should see your prune settings like this
https://www.talkimg.com/images/2024/04/24/r2Us8.jpeg

if it's checked ✔️  then you  are pruned and running  re-index will probably  start the whole sync process  from the beginning  just as @nc50lc posted in his comment
If not then  read this again
Quote
Or is your blockchain not pruned?
Because it will seemingly do IBD but it's just processing the existing blocks on your disk.
Are you using Bitcoin-qt (with GUI)? Does it show "Processing Blocks on disk", if so, that's just "reindexing"... not downloading.