Commit 4c7ac3ba authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4771 use a txn mutex to protect the txn lock tree set refs[t:4771]

git-svn-id: file:///svn/toku/tokudb@42930 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6a8d530b
......@@ -215,6 +215,7 @@ struct __toku_db_txn_internal {
TOKU_ISOLATION iso;
DB_TXN *child;
struct toku_list dbs_that_must_close_before_abort;
toku_pthread_mutex_t txn_mutex;
};
struct __toku_db_txn_external {
struct __toku_db_txn external_part;
......
......@@ -12,6 +12,7 @@ static int
toku_txn_add_lt(DB_TXN* txn, toku_lock_tree* lt) {
int r = ENOSYS;
assert(txn && lt);
toku_mutex_lock(&db_txn_struct_i(txn)->txn_mutex);
toku_lth* lth = db_txn_struct_i(txn)->lth;
// we used to initialize the transaction's lth during begin.
// Now we initialize the lth only if the transaction needs the lth, here
......@@ -33,6 +34,7 @@ toku_txn_add_lt(DB_TXN* txn, toku_lock_tree* lt) {
toku_lt_add_ref(lt);
r = 0;
cleanup:
toku_mutex_unlock(&db_txn_struct_i(txn)->txn_mutex);
return r;
}
......
......@@ -53,6 +53,7 @@ toku_txn_destroy(DB_TXN *txn) {
(void) __sync_fetch_and_sub(&txn->mgrp->i->open_txns, 1);
assert(txn->mgrp->i->open_txns>=0);
toku_txn_destroy_txn(db_txn_struct_i(txn)->tokutxn);
toku_mutex_destroy(&db_txn_struct_i(txn)->txn_mutex);
#if !TOKUDB_NATIVE_H
toku_free(db_txn_struct_i(txn));
#endif
......@@ -502,6 +503,7 @@ toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags, bool
db_txn_struct_i(result->parent)->child = result;
}
toku_mutex_init(&db_txn_struct_i(result)->txn_mutex, NULL);
(void) __sync_fetch_and_add(&env->i->open_txns, 1);
*txn = result;
......
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