Commit 2bf2bb14 authored by Yoni Fogel's avatar Yoni Fogel

[t:5110] Closes #5110 Skip taking the txn_manager lock for read-only...

[t:5110] Closes #5110 Skip taking the txn_manager lock for read-only transactions during note_abort/commit

git-svn-id: file:///svn/toku/tokudb@44758 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6c8439be
...@@ -402,8 +402,8 @@ void toku_txn_close_txn(TOKUTXN txn) { ...@@ -402,8 +402,8 @@ void toku_txn_close_txn(TOKUTXN txn) {
} }
static int remove_txn (OMTVALUE hv, u_int32_t UU(idx), void *txnv) static int remove_txn (OMTVALUE hv, u_int32_t UU(idx), void *txnv)
// Effect: This function is called on every open BRT that a transaction used. // Effect: This function is called on every open FT that a transaction used.
// This function removes the transaction from that BRT. // This function removes the transaction from that FT.
{ {
FT h = hv; FT h = hv;
TOKUTXN txn = txnv; TOKUTXN txn = txnv;
......
...@@ -751,6 +751,13 @@ static void invalidate_xa_xid (TOKU_XA_XID *xid) { ...@@ -751,6 +751,13 @@ static void invalidate_xa_xid (TOKU_XA_XID *xid) {
} }
void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
if (!txn->begin_was_logged) {
//Read only transaction
invariant(txn->state==TOKUTXN_LIVE);
invariant(txn->num_pin==0);
txn->state = TOKUTXN_ABORTING;
goto done;
}
toku_mutex_lock(&txn_manager->txn_manager_lock); toku_mutex_lock(&txn_manager->txn_manager_lock);
if (txn->state==TOKUTXN_PREPARING) { if (txn->state==TOKUTXN_PREPARING) {
invalidate_xa_xid(&txn->xa_xid); invalidate_xa_xid(&txn->xa_xid);
...@@ -762,15 +769,24 @@ void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { ...@@ -762,15 +769,24 @@ void toku_txn_manager_note_abort_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
// hot index is done with that leafentry // hot index is done with that leafentry
while (txn->num_pin > 0) { while (txn->num_pin > 0) {
toku_cond_wait( toku_cond_wait(
&txn_manager->wait_for_unpin_of_txn, &txn_manager->wait_for_unpin_of_txn,
&txn_manager->txn_manager_lock &txn_manager->txn_manager_lock
); );
} }
txn->state = TOKUTXN_ABORTING; txn->state = TOKUTXN_ABORTING;
toku_mutex_unlock(&txn_manager->txn_manager_lock); toku_mutex_unlock(&txn_manager->txn_manager_lock);
done:
return;
} }
void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
if (!txn->begin_was_logged) {
//Read only transaction
invariant(txn->state==TOKUTXN_LIVE);
invariant(txn->num_pin==0);
txn->state = TOKUTXN_COMMITTING;
goto done;
}
toku_mutex_lock(&txn_manager->txn_manager_lock); toku_mutex_lock(&txn_manager->txn_manager_lock);
if (txn->state==TOKUTXN_PREPARING) { if (txn->state==TOKUTXN_PREPARING) {
invalidate_xa_xid(&txn->xa_xid); invalidate_xa_xid(&txn->xa_xid);
...@@ -788,6 +804,8 @@ void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { ...@@ -788,6 +804,8 @@ void toku_txn_manager_note_commit_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
} }
txn->state = TOKUTXN_COMMITTING; txn->state = TOKUTXN_COMMITTING;
toku_mutex_unlock(&txn_manager->txn_manager_lock); toku_mutex_unlock(&txn_manager->txn_manager_lock);
done:
return;
} }
int toku_txn_manager_recover_txn ( int toku_txn_manager_recover_txn (
......
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