Library Version 12.1.6.2

Programmer notes FAQ
Prev | Chapter 17. Programmer Notes | Next

## Programmer notes FAQ

1. What priorities should threads/tasks executing Berkeley DB functions be given?

   Tasks executing Berkeley DB functions should have the same, or roughly equivalent, system priorities. For example, it can be dangerous to give tasks of control performing checkpoints a lower priority than tasks of control doing database lookups, and starvation can sometimes result.

2. Why isn't the C++ API exception safe?

   The Berkeley DB C++ API is a thin wrapper around the C API that maps most return values to exceptions, and gives the C++ handles the same lifecycles as their C counterparts. One consequence is that if an exception occurs while a cursor or transaction handle is open, the application must explicitly close the cursor or abort the transaction.

   Applications can be simplified and bugs avoided by creating wrapper classes around DBC and TXN that call the appropriate cleanup method in the wrapper's destructor. By creating an instance of the wrappers on the stack, C++ scoping rules will ensure that the destructor is called before exception handling unrolls the block that contains the wrapper object.

3. How do I handle a "pass 4" error when trying to run one of the example Performance Event Monitoring scripts on my Linux system? The library was configured with `--enable-dtrace` and built without error.

   A Linux installation can have SystemTap support for kernel probe points without including the kernel "utrace" module needed to use userspace probes. Pass 4 errors can occur when this required userspace support is not present.

4. I have a program with multiple threads running on multi-core systems, and it uses a shared DB handle for all the threads. The program does not behave as well as I expect and I see a lot of contention on the dbp->mutex, what should I do to reduce this contention ?

   When running multi-threaded program on a multi-core/multi-processor system, we suggest using a DB handle per thread instead of using a shared handle accorss threads. Since many operations(like creating cursors) requires to lock the DB handle first, and if using a shared handle, there could be a lot of lock contention on the handle.

Prev | Up | Next
Performance Event Monitoring | Home | Chapter 18. The Locking Subsystem