Commit 3608dcd1 authored by Yoni Fogel's avatar Yoni Fogel

closes #5149 Skips taking MO lock for readonly transactions on

commit, abort, and prepare

git-svn-id: file:///svn/toku/tokudb@44989 c7de825b-a66e-492c-adef-691d508d4ae1
parent 98d239de
...@@ -287,18 +287,12 @@ int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, LSN oplsn, ...@@ -287,18 +287,12 @@ int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, LSN oplsn,
txn->progress_poll_fun = poll; txn->progress_poll_fun = poll;
txn->progress_poll_fun_extra = poll_extra; txn->progress_poll_fun_extra = poll_extra;
if (txn->begin_was_logged) { if (!toku_txn_is_read_only(txn)) {
r = toku_log_xcommit(txn->logger, &txn->do_fsync_lsn, 0, txn, txn->txnid64); r = toku_log_xcommit(txn->logger, &txn->do_fsync_lsn, 0, txn, txn->txnid64);
if (r != 0) { if (r != 0) {
goto cleanup; goto cleanup;
} }
} }
else {
// Did no work.
invariant(txn->roll_info.num_rollentries == 0);
// Was not prepared.
invariant(txn->do_fsync_lsn.lsn == ZERO_LSN.lsn);
}
// If !txn->begin_was_logged, we could skip toku_rollback_commit // If !txn->begin_was_logged, we could skip toku_rollback_commit
// but it's cheap (only a number of function calls that return immediately) // but it's cheap (only a number of function calls that return immediately)
// since there were no writes. Skipping it would mean we would need to be careful // since there were no writes. Skipping it would mean we would need to be careful
...@@ -328,18 +322,12 @@ int toku_txn_abort_with_lsn(TOKUTXN txn, LSN oplsn, ...@@ -328,18 +322,12 @@ int toku_txn_abort_with_lsn(TOKUTXN txn, LSN oplsn,
int r; int r;
txn->do_fsync = FALSE; txn->do_fsync = FALSE;
if (txn->begin_was_logged) { if (!toku_txn_is_read_only(txn)) {
r = toku_log_xabort(txn->logger, &txn->do_fsync_lsn, 0, txn, txn->txnid64); r = toku_log_xabort(txn->logger, &txn->do_fsync_lsn, 0, txn, txn->txnid64);
if (r != 0) { if (r != 0) {
goto cleanup; goto cleanup;
} }
} }
else {
// Did no work.
invariant(txn->roll_info.num_rollentries == 0);
// Was not prepared.
invariant(txn->do_fsync_lsn.lsn == ZERO_LSN.lsn);
}
// If !txn->begin_was_logged, we could skip toku_rollback_abort // If !txn->begin_was_logged, we could skip toku_rollback_abort
// but it's cheap (only a number of function calls that return immediately) // but it's cheap (only a number of function calls that return immediately)
// since there were no writes. Skipping it would mean we would need to be careful // since there were no writes. Skipping it would mean we would need to be careful
...@@ -360,7 +348,7 @@ static void copy_xid (TOKU_XA_XID *dest, TOKU_XA_XID *source) { ...@@ -360,7 +348,7 @@ static void copy_xid (TOKU_XA_XID *dest, TOKU_XA_XID *source) {
int toku_txn_prepare_txn (TOKUTXN txn, TOKU_XA_XID *xa_xid) { int toku_txn_prepare_txn (TOKUTXN txn, TOKU_XA_XID *xa_xid) {
int r = 0; int r = 0;
if (txn->parent || !txn->begin_was_logged) { if (txn->parent || toku_txn_is_read_only(txn)) {
// nothing to do if there's a parent, or if it's read-only // nothing to do if there's a parent, or if it's read-only
goto cleanup; goto cleanup;
} }
...@@ -526,6 +514,19 @@ toku_maybe_log_begin_txn_for_write_operation(TOKUTXN txn) { ...@@ -526,6 +514,19 @@ toku_maybe_log_begin_txn_for_write_operation(TOKUTXN txn) {
toku_txn_unlock(txn); toku_txn_unlock(txn);
} }
bool
toku_txn_is_read_only(TOKUTXN txn) {
if (!txn->begin_was_logged) {
// Did no work.
invariant(txn->roll_info.num_rollentries == 0);
// Was not prepared.
invariant(txn->do_fsync_lsn.lsn == ZERO_LSN.lsn);
invariant(toku_omt_size(txn->open_fts) == 0);
return true;
}
return false;
}
#include <valgrind/helgrind.h> #include <valgrind/helgrind.h>
void __attribute__((__constructor__)) toku_txn_status_helgrind_ignore(void); void __attribute__((__constructor__)) toku_txn_status_helgrind_ignore(void);
void void
......
...@@ -114,6 +114,7 @@ struct tokulogger_preplist { ...@@ -114,6 +114,7 @@ struct tokulogger_preplist {
int toku_logger_recover_txn (TOKULOGGER logger, struct tokulogger_preplist preplist[/*count*/], long count, /*out*/ long *retp, u_int32_t flags); int toku_logger_recover_txn (TOKULOGGER logger, struct tokulogger_preplist preplist[/*count*/], long count, /*out*/ long *retp, u_int32_t flags);
void toku_maybe_log_begin_txn_for_write_operation(TOKUTXN txn); void toku_maybe_log_begin_txn_for_write_operation(TOKUTXN txn);
bool toku_txn_is_read_only(TOKUTXN txn);
#if defined(__cplusplus) || defined(__cilkplusplus) #if defined(__cplusplus) || defined(__cilkplusplus)
} }
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment