This discussion is archived
1 Reply Latest reply: Jan 26, 2012 1:01 PM by Paula B RSS

BDB Functions from Callbacks

857786 Newbie
Currently Being Moderated
I am pasting a write that draw my attention from another thread:
Commited transaction durability and DB_REP_HANDLE_DEAD

The following is not completely clear to me:
"Yes, it is true that you must refrain from invoking any Berkeley DB
functions from within a callback function."

What does that mean exactly?
In particular, is there any problem if fro example i receive DB_EVENT_REP_MASTER, is there any problem opening a DB table from the thread context that receives the event.
This is currently the behavior of our application and we have not encountered around this.

Thx in advance
  • 1. Re: BDB Functions from Callbacks
    Paula B Explorer
    Currently Being Moderated
    The BDB library is not re-entrant, so there is a strong possibility that a thread executing a BDB callback will self-deadlock if it makes another BDB call. You seem to be getting lucky in the particular case you are trying, but a slight change in timing or the other things going on in your application at the time could easily result in a deadlock. This is why we don't support making BDB calls from inside a BDB callback.

    Generally, a BDB application inside the callback sets an internal variable of some kind to indicate that the event was received. Then another application thread or process acts on that variable, making any needed BDB calls.

    We have a suggestion that might help in your particular case. It is possible to open databases for read and write access on a replication client. Any attempt to perform an actual write operation will fail on a client, but the open will succeed. So you can pre-open your databases for eventual write access while the site is still a client. This will allow the write operations to succeed after the site becomes master

    Paula Bingham


  • Correct Answers - 10 points
  • Helpful Answers - 5 points