Bitcoin Forum
June 07, 2024, 10:38:41 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: What is the cleanest way to recover from an abruptly terminated Bitcoin Core?  (Read 56 times)
NotATether (OP)
Legendary
*
Offline Offline

Activity: 1624
Merit: 6879


bitcoincleanup.com / bitmixlist.org


View Profile WWW
February 13, 2021, 07:04:56 PM
 #1

Long story short, the server my node is hosted on locked out of the network, so I had to power cycle it to connect to it again. Since it wasn't a software reboot, Core did not exit gracefully. At first when I tried to start Core again I got errors related to lock files .bitcoin/.lock and ./bitcoin/wallets/.walletlock, which I both deleted. I also deleted .bitcoin/bitcoind.pid in case that was also used as a lock file.

So having done all that when I start bitcoind (0.20.1 on Linux), I get a message in standard output telling me that, understandably, the block data is corrupted, and that to fix it I have to run -reindex or -reindex-chainstate again.

Code:
2021-02-13T18:46:38Z init message: Loading block index...
2021-02-13T18:46:38Z Opening LevelDB in /home/redacted/.bitcoin/blocks/index
2021-02-13T18:46:38Z Fatal LevelDB error: IO error: lock /home/redacted/.bitcoin/blocks/index/LOCK: Resource temporarily unavailable
2021-02-13T18:46:38Z You can use -debug=leveldb to get more complete diagnostic messages
2021-02-13T18:46:38Z Fatal LevelDB error: IO error: lock /home/redacted/.bitcoin/blocks/index/LOCK: Resource temporarily unavailable
2021-02-13T18:46:38Z : Error opening block database.
Please restart with -reindex or -reindex-chainstate to recover.

Two questions:

1. Is -reindex-chainstate enough to fix the corrupted block files, or do I have to do a full -reindex? (Bandwidth is not an issue).
2. Is there anything else I need to do to gracefully recover an interrupted bitcoin core?

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DaveF
Legendary
*
Offline Offline

Activity: 3500
Merit: 6320


Crypto Swap Exchange


View Profile WWW
February 13, 2021, 07:13:52 PM
 #2

....
1. Is -reindex-chainstate enough to fix the corrupted block files, or do I have to do a full -reindex? (Bandwidth is not an issue).
2. Is there anything else I need to do to gracefully recover an interrupted bitcoin core?

You will not know till you try. Depends on how badly everything crapped when it crashed. Others might have a better answer but I have had it both ways depending on what the node was doing at the time. I don't know your server but if you are using some caching controller setup when you hit the rest button who knows what data was actually on the drive.

Not much else you can do to recover, it is what it is, a database has to be checked / rebuilt.

-Dave


█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
February 14, 2021, 02:59:50 AM
 #3

1. Is -reindex-chainstate enough to fix the corrupted block files, or do I have to do a full -reindex? (Bandwidth is not an issue).
Reindexing the chainstate is faster, Bitcoin Core doesn't have to validate and reindex all the blocks in addition to the chainstate. It took me 2 hours to finish reindexing chainstate as opposed to the 6 hours it took for me to do a full reindex. It would depend on your type of corruption to the files to determine which option you should run. Does it throw an error when reading the chainstate or the blocks?
2. Is there anything else I need to do to gracefully recover an interrupted bitcoin core?
\
Database corruption is the only issue that I have during an unclean shutdown. Nothing else should be affected.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
NotATether (OP)
Legendary
*
Offline Offline

Activity: 1624
Merit: 6879


bitcoincleanup.com / bitmixlist.org


View Profile WWW
February 14, 2021, 03:29:20 AM
 #4

...if you are using some caching controller setup when you hit the rest button who knows what data was actually on the drive.

I can't remember if I have writeback enabled on my disks (yes disks I run them in RAID0) but I'm positive that the block database was the only thing that could've been written to at the time of reset, everything else is just web servers that became idle as a result of loss of connectivity.

Does it throw an error when reading the chainstate or the blocks?

Unfortunately it's an error related to the blocks database as can be seen in the logs (Error opening block database) meaning I have to do a full -reindex. Shouldn't take longer than a couple hours on my hardware though.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!