Nested Transactions

A nested transaction is used to provide a transactional guarantee for a subset of operations performed within the scope of a larger transaction. Doing this allows you to commit and abort the subset of operations independently of the larger transaction.

The rules to the usage of a nested transaction are as follows:

To create a nested transaction, simply pass the parent transaction's handle when you created the nested transaction's handle. For example:

    // parent transaction
    DbTxn *parentTxn, *childTxn;
    ret = myEnv.txn_begin(NULL, &parentTxn, 0);
    // child transaction
    ret = myEnv.txn_begin(parent_txn, &childTxn, 0);