Commit 6ddd159a authored by Yoni Fogel's avatar Yoni Fogel

refs #5117 Add documentation for txn optimizations

Use wrapper function toku_txn_is_read_only whenever it doesn't make sense to access variable directly

git-svn-id: file:///svn/toku/tokudb@45209 c7de825b-a66e-492c-adef-691d508d4ae1
parent ee27f373
......@@ -3068,8 +3068,7 @@ log_open_txn (OMTVALUE txnv, u_int32_t UU(index), void *extra) {
FILENUMS open_filenums;
uint32_t num_filenums = toku_omt_size(txn->open_fts);
FILENUM array[num_filenums];
if (!txn->begin_was_logged) {
invariant(num_filenums == 0);
if (toku_txn_is_read_only(txn)) {
goto cleanup;
}
else {
......
......@@ -349,7 +349,10 @@ 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 r = 0;
if (txn->parent || toku_txn_is_read_only(txn)) {
// nothing to do if there's a parent, or if it's read-only
// We do not prepare children.
//
// Readonly transactions do the same if they commit or abort, so
// XA guarantees are free. No need to pay for overhead of prepare.
goto cleanup;
}
toku_txn_manager_add_prepared_txn(txn->logger->txn_manager, txn);
......
......@@ -551,7 +551,7 @@ void toku_txn_manager_finish_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
r = toku_omt_delete_at(txn_manager->live_root_txns, idx);
invariant_zero(r);
if (txn->begin_was_logged || garbage_collection_debug) {
if (!toku_txn_is_read_only(txn) || garbage_collection_debug) {
if (!is_snapshot) {
// If it's a snapshot, we already calculated index_in_snapshot_txnids.
// Otherwise, calculate it now.
......@@ -693,7 +693,14 @@ static void invalidate_xa_xid (TOKU_XA_XID *xid) {
}
void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
// Purpose:
// Delay until any indexer is done pinning this transaction.
// Update status of a transaction from live->aborting (or prepared->aborting)
// Do so in a thread-safe manner that does not conflict with hot indexing or
// begin checkpoint.
if (toku_txn_is_read_only(txn)) {
// Neither hot indexing nor checkpoint do any work with readonly txns,
// so we can skip taking the txn_manager lock here.
invariant(txn->state==TOKUTXN_LIVE);
txn->state = TOKUTXN_ABORTING;
goto done;
......@@ -720,7 +727,14 @@ done:
}
void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
// Purpose:
// Delay until any indexer is done pinning this transaction.
// Update status of a transaction from live->committing (or prepared->committing)
// Do so in a thread-safe manner that does not conflict with hot indexing or
// begin checkpoint.
if (toku_txn_is_read_only(txn)) {
// Neither hot indexing nor checkpoint do any work with readonly txns,
// so we can skip taking the txn_manager lock here.
invariant(txn->state==TOKUTXN_LIVE);
txn->state = TOKUTXN_COMMITTING;
goto done;
......
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