Configuring the Transaction Subsystem

Most of the configuration activities that you need to perform for your transactional DB application will involve the locking and logging subsystems. See Concurrency and Managing DB Files for details.

However, there are a couple of things that you can do to configure your transaction subsystem directly. These things are:

For example:

#include "db_cxx.h"

...

int main(void)
{
    u_int32_t env_flags = DB_CREATE     |  // If the environment does not
                                           // exist, create it.
                          DB_INIT_LOCK  |  // Initialize locking
                          DB_INIT_LOG   |  // Initialize logging
                          DB_INIT_MPOOL |  // Initialize the cache
                          DB_THREAD     |  // Free-thread the env handle
                          DB_INIT_TXN;     // Initialize transactions

    std::string envHome("/export1/testEnv");
    DbEnv myEnv(0);

    try {

        // Configure a maximum transaction timeout of 1 second.
        myEnv.set_timeout(1000000, DB_SET_TXN_TIMEOUT);
        // Configure 40 maximum transactions.
        myEnv.set_tx_max(40);
        myEnv.open(envHome.c_str(), env_flags, 0);

        // From here, you open your databases, proceed with your 
        // database operations, and respond to deadlocks as 
        // is normal (omitted for brevity).

        
        ...