Commit 66a0df48 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:5038], fix some bugs in transactions after code review

git-svn-id: file:///svn/toku/tokudb@44352 c7de825b-a66e-492c-adef-691d508d4ae1
parent b8bbdd3f
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "txn_manager.h" #include "txn_manager.h"
struct txn_manager { struct txn_manager {
toku_mutex_t txn_manager_lock; // a lock protecting live_list_reverse and snapshot_txnids for now TODO: revisit this decision toku_mutex_t txn_manager_lock; // a lock protecting this object
OMT live_txns; // a sorted tree. Old comment said should be a hashtable. Do we still want that? OMT live_txns; // a sorted tree. Old comment said should be a hashtable. Do we still want that?
OMT live_root_txns; // a sorted tree. OMT live_root_txns; // a sorted tree.
OMT snapshot_txnids; //contains TXNID x | x is snapshot txn OMT snapshot_txnids; //contains TXNID x | x is snapshot txn
...@@ -682,7 +682,7 @@ int toku_txn_manager_iter_over_live_txns( ...@@ -682,7 +682,7 @@ int toku_txn_manager_iter_over_live_txns(
void toku_txn_manager_add_prepared_txn(TXN_MANAGER txn_manager, TOKUTXN txn) { void toku_txn_manager_add_prepared_txn(TXN_MANAGER txn_manager, TOKUTXN txn) {
toku_mutex_lock(&txn_manager->txn_manager_lock); toku_mutex_lock(&txn_manager->txn_manager_lock);
assert(txn->state==TOKUTXN_LIVE); assert(txn->state==TOKUTXN_LIVE);
txn->state = TOKUTXN_PREPARING; // This state transition must be protected against begin_checkpoint. Right now it uses the ydb lock. txn->state = TOKUTXN_PREPARING; // This state transition must be protected against begin_checkpoint
toku_list_push(&txn_manager->prepared_txns, &txn->prepared_txns_link); toku_list_push(&txn_manager->prepared_txns, &txn->prepared_txns_link);
toku_mutex_unlock(&txn_manager->txn_manager_lock); toku_mutex_unlock(&txn_manager->txn_manager_lock);
} }
......
...@@ -207,7 +207,7 @@ static void fill_prov_info( ...@@ -207,7 +207,7 @@ static void fill_prov_info(
prov_txns[i] = txn; prov_txns[i] = txn;
if (txn) { if (txn) {
prov_states[i] = toku_txn_get_state(txn); prov_states[i] = toku_txn_get_state(txn);
if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_LIVE) { if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_PREPARING) {
// pin // pin
toku_txn_manager_pin_live_txn_unlocked(txn_manager, txn); toku_txn_manager_pin_live_txn_unlocked(txn_manager, txn);
} }
...@@ -236,7 +236,7 @@ static void release_txns( ...@@ -236,7 +236,7 @@ static void release_txns(
} }
// see if any txn pinned before bothering to grab txn_manager lock // see if any txn pinned before bothering to grab txn_manager lock
for (u_int32_t i = 0; i < num_provisional; i++) { for (u_int32_t i = 0; i < num_provisional; i++) {
if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_LIVE) { if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_PREPARING) {
assert(prov_txns[i]); assert(prov_txns[i]);
some_txn_pinned = TRUE; some_txn_pinned = TRUE;
} }
...@@ -244,7 +244,7 @@ static void release_txns( ...@@ -244,7 +244,7 @@ static void release_txns(
if (some_txn_pinned) { if (some_txn_pinned) {
toku_txn_manager_suspend(txn_manager); toku_txn_manager_suspend(txn_manager);
for (u_int32_t i = 0; i < num_provisional; i++) { for (u_int32_t i = 0; i < num_provisional; i++) {
if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_LIVE) { if (prov_states[i] == TOKUTXN_LIVE || prov_states[i] == TOKUTXN_PREPARING) {
toku_txn_manager_unpin_live_txn_unlocked(txn_manager, prov_txns[i]); toku_txn_manager_unpin_live_txn_unlocked(txn_manager, prov_txns[i]);
} }
} }
......
...@@ -169,8 +169,8 @@ toku_txn_abort_only(DB_TXN * txn, ...@@ -169,8 +169,8 @@ toku_txn_abort_only(DB_TXN * txn,
} }
HANDLE_PANICKED_ENV(txn->mgrp); HANDLE_PANICKED_ENV(txn->mgrp);
assert_zero(r); assert_zero(r);
r = toku_txn_release_locks(txn);
toku_txn_complete_txn(db_txn_struct_i(txn)->tokutxn); toku_txn_complete_txn(db_txn_struct_i(txn)->tokutxn);
r = toku_txn_release_locks(txn);
return r; return r;
} }
......
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