mdbx-test: simplify txn commit/abort path.

Change-Id: I86780a43f9f7b1a52dfa97168ad53cf7389d5e2e
This commit is contained in:
Leonid Yuriev 2020-05-22 17:22:43 +03:00
parent 2e7e1079c4
commit a85ae436eb

View File

@ -179,26 +179,23 @@ void testcase::txn_begin(bool readonly, unsigned flags) {
} }
int testcase::breakable_commit() { int testcase::breakable_commit() {
int rc = MDBX_SUCCESS;
log_trace(">> txn_commit"); log_trace(">> txn_commit");
assert(txn_guard); assert(txn_guard);
MDBX_txn *txn = txn_guard.release(); MDBX_txn *txn = txn_guard.release();
txn_inject_writefault(txn); txn_inject_writefault(txn);
int err = mdbx_txn_commit(txn); int rc = mdbx_txn_commit(txn);
if (unlikely(err != MDBX_SUCCESS)) { if (unlikely(rc != MDBX_SUCCESS) &&
if (err == MDBX_MAP_FULL && config.params.ignore_dbfull) { (rc != MDBX_MAP_FULL || !config.params.ignore_dbfull))
rc = err; failure_perror("mdbx_txn_commit()", rc);
err = mdbx_txn_abort(txn);
if (unlikely(err != MDBX_SUCCESS && err != MDBX_THREAD_MISMATCH && if (need_speculum_assign) {
err != MDBX_BAD_TXN)) need_speculum_assign = false;
failure_perror("mdbx_txn_abort()", err); if (unlikely(rc != MDBX_SUCCESS))
if (need_speculum_assign) speculum = speculum_commited;
speculum = speculum_commited; else
} else speculum_commited = speculum;
failure_perror("mdbx_txn_commit()", err); }
} else if (need_speculum_assign)
speculum_commited = speculum;
log_trace("<< txn_commit: %s", rc ? "failed" : "Ok"); log_trace("<< txn_commit: %s", rc ? "failed" : "Ok");
return rc; return rc;
@ -225,8 +222,7 @@ void testcase::txn_end(bool abort) {
MDBX_txn *txn = txn_guard.release(); MDBX_txn *txn = txn_guard.release();
if (abort) { if (abort) {
int err = mdbx_txn_abort(txn); int err = mdbx_txn_abort(txn);
if (unlikely(err != MDBX_SUCCESS && err != MDBX_THREAD_MISMATCH && if (unlikely(err != MDBX_SUCCESS))
err != MDBX_BAD_TXN))
failure_perror("mdbx_txn_abort()", err); failure_perror("mdbx_txn_abort()", err);
if (need_speculum_assign) if (need_speculum_assign)
speculum = speculum_commited; speculum = speculum_commited;