Most of the configuration activities that you need to perform for your transactional BDB XML application will involve the locking and logging subsystems. See Concurrency and Managing BDB XML Files for details.
However, you can also configure the maximum number of simultaneous transactions needed by your application. In general, you should not need to do this unless you use deeply nested transactions or you have many threads all of which have active transactions. In addition, you may need to configure a higher maximum number of transactions if you are using snapshot isolation. See Snapshot Isolation Transactional Requirements for details.
By default, your application can support 20 active transactions.
You can set the maximum number of simultaneous
transactions supported by your application using
the
DB_ENV->set_tx_max()
method. Note that this method must be called
before the environment has been opened.
If your application has exceeded this maximum value, then any attempt to begin a new transaction will fail.
This value can also be set using the
DB_CONFIG
file's
set_tx_max
parameter. Remember that
the DB_CONFIG
must reside in your
environment home directory.
For example:
#include "DbXml.hpp" ... using namespace DbXml; 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 DB_ENV *myEnv = NULL; XmlManager *myManager = NULL; char *envHome = "/export1/testEnv"; int dberr; dberr = db_env_create(&myEnv, 0); if (dberr) { std::cout << "Unable to create environment: " << db_strerror(dberr) << std::endl; if (myEnv) myEnv->close(myEnv, 0); return (EXIT_FAILURE); } // Configure 40 maximum transactions. myEnv->set_tx_max(myEnv, 40); myEnv->open(myEnv, envHome, env_flags, 0); myManager = new XmlManager(myEnv, 0); // From here, you open your containers, proceed with your // container operations, and respond to deadlocks as // is normal (omitted for brevity). ...