Title: create corrupted database / block Post by: 22bits on May 19, 2024, 05:13:30 AM I previously had a slight issue where my computer died and it corrupted the block so I reran bitcoind with the -reindex option to correct the block issue. I was looking into on startup detecting whether or not the chain / db is corrupted and was hoping to create the condition of the database being corrupted. I have tried to create a condition where the db is corrupted, but just stopping power does not seem to work (must be power outage at particular spot in the chain maintenance). Is there some reliable way to create a corrupted db to use for testing? (on linux: ubuntu direct connect)
Title: Re: create corrupted database / block Post by: 22bits on May 19, 2024, 06:04:27 AM Just a follow on: I just started renaming blocks in blocks, chainstate and received the startup error:
Code: 2024-05-19T05:46:48Z Initializing chainstate Chainstate [ibd] @ height -1 (null) Title: Re: create corrupted database / block Post by: Mia Chloe on May 19, 2024, 07:00:31 AM Firstly Op if I may ask , why are you trying to corrupt the drive? Probably it may exist, but I haven't really come across a drive corruption after the device have been successfully synced with the block chain. Majority of the cases I have come across especially on this forum are those where the drive got corrupt during the process of syncing with the block chain. Sometimes as a result of power outage and sometimes because the block chain was synced to a drive with the wrong format like FAT32 which sometimes has issues when the file load is huge.
RAM also has a huge role to play when it comes to computation during the syncronisation process which will attribute how long it will take before the sync is completed. Title: Re: create corrupted database / block Post by: 22bits on May 19, 2024, 07:06:08 AM Thanks for asking. Basically the other day when initially loading the blockchain there was a sudden power outage. When the system came back up the bitcoind errored out. Eventually my plan is to have a script which checks if the blockchain (local data stored on my system) is intact (this will run as a ExecStartPre in systemd), and then if not have a systemd process which will in those cases run the bitcoind with the -reindex option. I already have a simple script which checks if the bitcoind is unable to start and will then hook it up to systemd process which runs with the -reindex in those cases.
Title: Re: create corrupted database / block Post by: NotATether on May 19, 2024, 07:31:06 AM You shouldn't try to simulate a power outage as that can actually damage your motherboard. What would be better for testing purposes would be to force-kill the bitcoind process - either by Task Manager or by sending SIGKILL (not sigterm) to it on Linux or Max.
Title: Re: create corrupted database / block Post by: ABCbits on May 20, 2024, 10:10:16 AM Is there some reliable way to create a corrupted db to use for testing? (on linux: ubuntu direct connect) Bitcoin Core check recent block when you open it. So you probably just need to edit recently created blk*dat or rev*dat files to achieve that goal. I said probably since i didn't try it on my own Bitcoin Core files. |