Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbAbort

Abort a transaction.

Declaration

CTDBRET ctdbAbort(CTHANDLE Handle)

  • Handle [in] the session handle. Any handle will work, but you save a tiny bit of CPU by using the session handle.

Description

ctdbAbort() aborts a transaction initiated with ctdbBegin() and releases all locks, both session-wide record locks (automatically acquired as a result of calling ctdbLock() and then reading a record from a table file), and manually-locked records (acquired by calling ctdbLockRecord() on an individual record). Locks acquired both inside and outside the transaction are released. This function also disables (turns off) session-wide record locking. Note that these lock-related behaviors can be changed from the default by calling ctdbSetKeepLock().

Returns

ctdbAbort() returns CTDBRET_OK if successful, or the c-tree error code on failure. Common causes of abort errors are calling ctdbAbort() twice in a row or calling ctdbAbort() after a successful call to ctdbCommit() or calling ctdbAbort() without calling ctdbBegin() first to start a transaction. Extreme circumstances, like the failure of computer hardware, can cause calls to ctdbCommit() and ctdbAbort() to fail. In situations like this, a common approach is to log an error and exit.

Example


ctdbBegin(pSession);

if (ctdbCreateTable(tHandle1,"table1",CTCREATE_NORMAL) == CTDBRET_OK)

ctdbCommit(pSession);

else

ctdbAbort(pSession);


See also

ctdbBegin(), ctdbClearSavePoint(), ctdbCommit(), ctdbRestoreSavePoint(), ctdbSetKeepLock(), ctdbSetSingleSavePoint(), Locking

TOCIndex