database files corrupted when laptop locked up #903

issue dooglus opened this issue on February 26, 2012
  1. dooglus commented at 8:52 PM on February 26, 2012: contributor

    I just had my laptop freeze and had to hard reboot.

    When it came back both the blockchain and addr databases were corrupted and failed to load.

    I had to restore an old backup to get bitcoin to run again.

    Is it possible to somehow keep the database files consistent even in the event of a power failure or OS lockup?

  2. gavinandresen commented at 9:17 PM on February 27, 2012: contributor

    We're only as good as BDB; see here: http://pybsddb.sourceforge.net/ref/transapp/reclimit.html

    In particular:

    "it is important to select hardware that does not do partial writes and does not cache data writes (or does not return that the data has been written to stable storage until it has either been written to stable storage or the actual writing of all of the data is guaranteed, barring catastrophic hardware failure -- that is, your disk drive exploding). You should also be aware that Berkeley DB does not protect against all cases of stable storage hardware failure, nor does it protect against hardware misbehavior."

  3. sipa commented at 10:07 PM on February 27, 2012: member

    I think the real problem is that in the end, bdb doesn't seem appropriate for end-user desktop systems...

  4. dooglus commented at 11:12 PM on February 27, 2012: contributor

    Perhaps something like 'backupwallet <destination>' but for all data files would be useful. I could write a crontab to copy the .bitcoin folder in the early hours of each morning, but there's no guarantee that the files I copy are in a consistent state.

    'backupdata <destination-dir>" could copy all 4 .dat files to the specified backup directory, for instance.

    Also, when a database file does become corrupted, the output in the terminal is very unhelpful. It doesn't indicate which of the files is corrupted (although scanning back up through the log can show which file was being read at the time) and offers the user no advice on how to proceed.

  5. laanwj commented at 2:45 PM on November 4, 2013: member

    Closing this; automatic recovery is somewhat better now.

  6. laanwj closed this on Nov 4, 2013

  7. suprnurd referenced this in commit 90adb89233 on Dec 5, 2017
  8. ptschip referenced this in commit 6f35b3be6a on Jan 17, 2018
  9. lateminer referenced this in commit 68c81c407a on Oct 30, 2019
  10. sipa referenced this in commit 77ccaf5cb9 on Apr 2, 2021
  11. sipa referenced this in commit cb8f70f488 on Apr 2, 2021
  12. sipa referenced this in commit a110aca93f on Apr 2, 2021
  13. sipa referenced this in commit bdca9bcb6c on Apr 23, 2021
  14. rebroad referenced this in commit 6e13b4e771 on Jun 23, 2021
  15. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me