Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:01:25+00:00 2026-05-25T23:01:25+00:00

I get some super annoying asserts when I try to delete the leveldb instance

  • 0

I get some super annoying asserts when I try to delete the leveldb instance and I’m not sure why it’s happening!

The assert is happening in the version_set.cc file:

void VersionSet::AppendVersion(Version* v) {
  // Make "v" current
  assert(v->refs_ == 0); // <---??? how do I avoid this assertion?
  // the rest of the source code is available in the link to version_set.cc
}

Additionally, it asserts in another place in the same file:

Version::~Version() {
  assert(refs_ == 0); // <-- Again... how do I avoid this one too?
  // the rest of the source code is available in the link to version_set.cc
}

Here is more background details on the usage in my system, I have a:

  • class ExtStorage (Extended Storage) which has a LevelDB::DB instance.
  • class EextStorageDotNet, which is the C++/CLI wrapper around the ExtStorage.
  • class AltStorage, which holds a pointer to an ExtStorage class (passed through the constructor):
  • class AltStorageDotNet, which is the C++/CLI wrapper around the AltStorage.

The alternate storage class looks like this:

class AltStorage{
    ExtStorage* instance;
public:
    AltStorage(ExtStorage* extStorage):instance(extStorage){}

    ~AltStorage(){
        delete instance;
        instance = NULL;
    }
};

The ExtStorage class looks like this:

class ExtStorage{
    leveldb::DB* mydb;
public:
    ExtStorage(/*some parameters*/){
         mydb = new leveldb::DB(/*parameters*/);
    }

    // Destructor
    ~ExtStorage() {
        Close();
    }

    // deletes the leveldb::DB instance
    void Close() {
        if(mydb == NULL) {
            delete mydb; // <-- Asserts every time I get here when using with the AltStorageDotNet
            mydb= NULL;

            // Close the L1 and L2 caches
            // only once (
        }
    }
}

The AltStorageDotNet class looks like this:

public ref class AltStorageDotNet{
    AltStorage* altInstance;
    ExtStorageDotNet^ extInstance;
public:
    AltStorageDotNet() {
        ExtStorage extStorage = new ExtStorage(/*params*/);
        altInstance = new AltStorage(extStorage);
        extInstance = gcnew ExtStorageDotNet(extStorage);
    }

    ~AltStorageDotNet(){
        delete altInstance;
        altInstance = NULL;
        // no need to delete extInstance since it was created with gcnew 
    }

    !AltStorageDotNet(){
        delete altInstance;
        altInstance = NULL;
        // no need to delete extInstance since it was created with gcnew
    }

    inline ExtStorageDotNet^ GetExtInstance(){return extInstance;}
};

The DotNet wrappers look like this:

public ref class ExtStorageDotNet{
private:
    ExtStorage* instance;
public:
    ExtStorageDotNet(ExtStorage* extStorage){
        instance = extStorage;
    }

    ~ExtStorageDotNet(){
        delete instance;
        instance = NULL;
    }

    !ExtStorageDotNet(){
        delete instance;
        instance = NULL;
    }

    void Close(){instance->Close();}
};

Whenever I use the ExtStorageDotNet wrapper in my C# application everything works good and there are no asserts. However, when I use the AltStorageDotNet wrapper and I access the ExtStorageDotNet wrapper, then I get the asserts when closing the database. This is all part of a test suite in which I initialize an instance for each test case and close it after each test case; the associated database files get deleted before a new test case begins. I don’t see any reason why it should happen and the assertion is not helpful in tracking down the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:01:26+00:00Added an answer on May 25, 2026 at 11:01 pm

    I got rid of the nested references, but that didn’t solve the problem. As it turns out, the issue causing this problem was not quite where I was looking at. The issue occurs when a user gets an iterator to the database and fails to delete the iterator prior to deleting the database. This was discussed in a google group relating to level db.

    // Caller should delete the iterator when it is no longer needed.
    // The returned iterator should be deleted before this db is deleted.
    virtual Iterator* NewIterator(const ReadOptions& options) = 0; 
    

    When the user gets the iterator they should delete it prior to deleting the db, otherwise they will get the assertion mentioned above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could I get some confirmations from the community that I'm not going mad, and
I have some class initialized in Appdelegate, but when I get this class instance
I've been practicing some animation on Android but I could not get my code
I write a custom dialog and try to get some data from its parent
To get some smooth graphics, I want to draw oversampled by factor 2 and
For some reason I get some warnings about non dll-interface class when building with
Where can I get some decent looking free ASP.Net or CSS themes?
I am trying to get some accurate runtime comparisons of PHP vs Python (and
I need to get some information that is contained in the MFT on a
I am trying to get some XML data with LINQ, but running into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.