Berkeley DB: DbTxn::commit
Полезная информация


#include <db_cxx.h>

int DbTxn::commit();


The DbTxn::commit method ends the transaction specified by the tid argument.

If DB_TXN_NOSYNC was not specified, a commit log record is written and flushed to disk, as are all previously written log records.

In the case of nested transactions, if the transaction is a parent transaction with unresolved (neither committed or aborted) child transactions, the child transactions are aborted and the commit of the parent will succeed.

In the case of nested transactions, if the transaction is a child transaction, its locks are not released, but are acquired by its parent. While the commit of the child transaction will succeed, the actual resolution of the child transaction is postponed until the parent transaction is committed or aborted, i.e., if its parent transaction commits, it will be committed, and if its parent transaction aborts, it will be aborted.

Any applications that require strict two-phase locking must not release any locks explicitly, leaving them all to be released by DbTxn::commit.

The DbTxn::commit method either returns errno or throws an exception that encapsulates an errno on failure, and 0 on success.


If a fatal error occurs in Berkeley DB, the DbTxn::commit method may fail and either return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY, at which point all subsequent database calls will also fail in the same way. Methods marked as returning errno will, by default, throw an exception that encapsulates the error information. The default error behavior can be changed, see DbException.

The DbTxn::commit method may fail and throw an exception for any of the errors specified for the following Berkeley DB and C library functions: abort(3), fcntl(3), fflush(3), fprintf(3), free(3), getpid(3), DbLockTab::vec, DbLog::put, malloc(3), memcpy(3), memset(3), strerror(3), vfprintf(3), and vsnprintf(3).

In addition, the DbTxn::commit method may fail and throw an exception or return errno for the following conditions:

The transaction was already aborted.



See Also

DbTxn::abort, DbTxn::commit, DbTxn::id and DbTxn::prepare.