2 Replies Latest reply: Jul 30, 2014 3:30 PM by 2720826 RSS

    How do I remove a DB from shared memory in Solaris 10?

    2720826

      I'm having trouble removing  an in-memory database placed in shared memory. I set SHM key and cache size, and then open an environment with flags: DB_CREATE | DB_SYSTEM_MEM | DB_INIT_MPOOL | DB_INIT_LOG | DB_INIT_LOCK | DB_INIT_TXN. I also set the flag DB_TXN_NOSYNC on the DbEnv. At the end, after closing all Db and DbEnv handles, I create a new DbEnv instance and call DbEnv::remove. That's when things get weird.

       

      If I have the force flag set to 0, then it throws an exception saying "DbEnv::remove: Device busy". The shared memory segments do not get removed in this case (checking with `ipcs -bom`).

       

      When the force flag is set to zero, the shared memory is released but the program crashes saying "Db::close: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery".

       

      What am I doing wrong?

        • 1. Re: How do I remove a DB from shared memory in Solaris 10?
          Charles Koester-Oracle

          This is curious, since a simple program similar to what is described is known to work. I've modified the standard sample program examples/cxx/EnvExample.cpp C++ to use an in-memory database, DB_SYSTEM_MEM, and DB_TXN_NOSYNC. The "Device busy" symptom occurs if the close of the environment handle is bypassed. I have not been able to reproduce the DB_RUNRECOVERY error.

           

          How does the program's use of Berkeley DB different from what is provided in EnvExample.cpp?

          Is it possible to send me the relevant portions of it?

           

          Regards,

          Charles Koester

          Oracle Berkeley DB

          • 2. Re: How do I remove a DB from shared memory in Solaris 10?
            2720826

            Thanks for confirming that it works in the sample. The modified sample worked in our environment as well, so I took a closer look at my code. I had a second open reference to the environment and was essentially trying to remove the same thing twice. Everything works as expected after fixing that.