Handle leveldb::DestroyDB() errors on wipe failure #6551

pull ajweiss wants to merge 1 commits into bitcoin:master from ajweiss:ajw_1508_destroydb_exceptions changing 1 files +2 −1
  1. ajweiss commented at 11:53 PM on August 12, 2015: contributor

    Add error checking to CLevelDBWrapper for errors from leveldb::DestroyDB(). Without it, if unlink() or DeleteFileW() fail to delete files, they will fail silent. If they fail to delete any files, CLevelDBWrapper will silently open and read the existing database.

    Typically any permissions issues would be caught by leveldb as it churns through many files as part of its compaction process, but it is conceivable that this could cause problems on Windows with anti-virus and indexing software.

  2. Handle leveldb::DestroyDB() errors on wipe failure
    Add error checking to CLevelDBWrapper for errors from
    leveldb::DestroyDB().  Without it, if unlink() or DeleteFileW() fail to
    delete files, they will fail silent.  If they fail to delete any files,
    CLevelDBWrapper will silently open and read the existing database.
    
    Typically any permissions issues would be caught by leveldb as it churns
    through many files as part of its compaction process, but it is
    conceivable that this could cause problems on Windows with anti-virus
    and indexing software.
    243b80d292
  3. dcousens commented at 12:09 AM on August 13, 2015: contributor

    utACK

  4. TheBlueMatt commented at 8:19 AM on August 13, 2015: member

    Not to bikeshed this, but we should figure out if we want to use the throw() syntax in function declarations. We have it in bool CLevelDBWrapper::WriteBatch(CLevelDBBatch& batch, bool fSync) throw(leveldb_error), but not in CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe), which is strange.

  5. ajweiss commented at 3:45 PM on August 13, 2015: contributor

    throw() is deprecated in C++11... so I vote we throw() it out entirely.

    Perhaps just a comment, like:

    // Throws leveldb_error
    bool WriteBatch(CLevelDBBatch& batch, bool fSync = false);
    

    ...seems like a sensible replacement?

  6. TheBlueMatt commented at 3:48 PM on August 13, 2015: member

    Yes, a comment would be very nice, indeed... Does clang have any compiler-enforced catch requirements?

    On August 13, 2015 6:45:22 PM GMT+03:00, Adam Weiss notifications@github.com wrote:

    throw() is deprecated in C++11... so I vote we throw() it out entirely.

    Perhaps just a comment, like:

    // Throws leveldb_error bool WriteBatch(CLevelDBBatch& batch, bool fSync = false);

    ...seems like a sensible replacement?


    Reply to this email directly or view it on GitHub: #6551 (comment)

  7. ajweiss commented at 4:38 PM on August 13, 2015: contributor

    I don't think any C++ compilers support checked exceptions. That said, it wouldn't be terrible to throw(all) the exceptions here out and replace them with return codes...

    On Thu, Aug 13, 2015 at 11:48 AM, Matt Corallo notifications@github.com wrote:

    Yes, a comment would be very nice, indeed... Does clang have any compiler-enforced catch requirements?

    On August 13, 2015 6:45:22 PM GMT+03:00, Adam Weiss < notifications@github.com> wrote:

    throw() is deprecated in C++11... so I vote we throw() it out entirely.

    Perhaps just a comment, like:

    // Throws leveldb_error bool WriteBatch(CLevelDBBatch& batch, bool fSync = false);

    ...seems like a sensible replacement?


    Reply to this email directly or view it on GitHub: #6551 (comment)

    — Reply to this email directly or view it on GitHub #6551 (comment).

  8. TheBlueMatt commented at 4:44 PM on August 13, 2015: member

    Yea, again, don't really want to bikeshed this, but I'm always in favor of removing exceptions.

    On August 13, 2015 7:38:32 PM GMT+03:00, Adam Weiss notifications@github.com wrote:

    I don't think any C++ compilers support checked exceptions. That said, it wouldn't be terrible to throw(all) the exceptions here out and replace them with return codes...

    On Thu, Aug 13, 2015 at 11:48 AM, Matt Corallo notifications@github.com wrote:

    Yes, a comment would be very nice, indeed... Does clang have any compiler-enforced catch requirements?

    On August 13, 2015 6:45:22 PM GMT+03:00, Adam Weiss < notifications@github.com> wrote:

    throw() is deprecated in C++11... so I vote we throw() it out entirely.

    Perhaps just a comment, like:

    // Throws leveldb_error bool WriteBatch(CLevelDBBatch& batch, bool fSync = false);

    ...seems like a sensible replacement?


    Reply to this email directly or view it on GitHub: #6551 (comment)

    — Reply to this email directly or view it on GitHub

    #6551 (comment).


    Reply to this email directly or view it on GitHub: #6551 (comment)

  9. ajweiss commented at 5:24 PM on August 13, 2015: contributor

    Naw, not bikeshedding. I'll pull them out and in the process will end up auditing a bunch of failure cases for leveldb. In light of recent reports of leveldb corruption, this is a good thing. Thanks for the feedback!

  10. ajweiss commented at 5:59 PM on August 14, 2015: contributor

    Although, of course, this means un-RAII-ifying the leveldb wrapper. I'm happy to do this, but I have doubts as to whether or not anyone else is going to like it (given that there's so much other stuff that is RAII)...

  11. dcousens commented at 11:32 AM on August 15, 2015: contributor

    @ajweiss why would it stop RAII-like behaviour?

  12. sipa commented at 1:25 PM on August 15, 2015: member

    utACK

  13. laanwj commented at 2:48 PM on August 17, 2015: member

    Please don't remove RAII behavior. If that means having to use exceptions for error reporting, that's that.

  14. laanwj commented at 2:49 PM on August 17, 2015: member

    utACK on the actual code

  15. laanwj merged this on Aug 17, 2015
  16. laanwj closed this on Aug 17, 2015

  17. laanwj referenced this in commit 39ddaeb8fe on Aug 17, 2015
  18. 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-20 09:15 UTC

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