Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Having trouble with BDB

e3cc0151-55a3-4b50-a862-472149af3ccaDec 22 2015 — edited Dec 23 2015

Hello,

I am looking for some help getting BDB working in my program.  It seems to work for a while but fails randomly and corrupts the database.

The DB pointer is saved to a structure that represents a thread.

struct processor {

    pthread_t t_processor;

    int state; // Marks this thread as active. 1=running, 0=stopping, -1=stopped.

    struct workercounters metrics;

    struct packet_head queue;

    __u8 *lzbuffer; // Buffer used for QuickLZ.

  DB *blocks; // DEDUP "block" database pointer. <-Saved here!

};

I initialize the database pointer by passing the DB pointer when the thread is initialized.

dbp_initialize(&thisprocessor->blocks);

The database is created or opened with DB_THREAD so I think it should be thread safe.  Maybe there is something I am missing in this part.

int dbp_initialize(DB **dbp){

int ret = 0;

if ((ret = db_create(dbp, NULL, 0)) != 0) {

logger2(LOGGING_DEBUG,LOGGING_DEBUG,"[DEDUP] Error creating database pointer.\n");

exit (1);

}

if ((ret = (*dbp)->open(*dbp, NULL, DATABASE, BLOCKS, DB_BTREE, DB_CREATE | DB_THREAD, 0664)) != 0) {

(*dbp)->err(*dbp, ret, "%s", DATABASE);

logger2(LOGGING_DEBUG,LOGGING_DEBUG,"[DEDUP] Opening database failed.\n");

exit (1);

}

logger2(LOGGING_DEBUG,LOGGING_DEBUG,"[DEDUP] Opening database success.\n");

return 0;

}

Now the problem is when I try to input new records into the database.  It seems to work for a while but eventually returns negative but no real indicator as to why.(apparently I cannot paste any more code)

[C] // Try inserting the key & data into the database. switch ((*dbp)->put(*dbp, NU - Pastebin.com

The full source code is online.

https://sourceforge.net/p/opennop/daemon/ci/feature/deduplication/~/tree/opennopd/

The data I am inserting is 128 bytes of binary data and the key is a 64 byte sha512 hash of that data.

Thanks so much.

This post has been answered by userBDBDMS-Oracle on Dec 22 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 20 2016
Added on Dec 22 2015
7 comments
1,758 views