Commit 9ccc6a9d authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4498], initialize a txn's lth on demand, in toku_txn_add_lt and not in the begin of a txn

git-svn-id: file:///svn/toku/tokudb@39758 c7de825b-a66e-492c-adef-691d508d4ae1
parent 28bf7dc3
...@@ -209,7 +209,7 @@ typedef enum __toku_isolation_level { ...@@ -209,7 +209,7 @@ typedef enum __toku_isolation_level {
struct __toku_db_txn_internal { struct __toku_db_txn_internal {
//TXNID txnid64; /* A sixty-four bit txn id. */ //TXNID txnid64; /* A sixty-four bit txn id. */
struct tokutxn *tokutxn; struct tokutxn *tokutxn;
struct __toku_lth *lth; //Hash table holding list of dictionaries this txn has touched struct __toku_lth *lth; //Hash table holding list of dictionaries this txn has touched, only initialized if txn touches a dictionary
u_int32_t flags; u_int32_t flags;
TOKU_ISOLATION iso; TOKU_ISOLATION iso;
DB_TXN *child; DB_TXN *child;
......
...@@ -2939,17 +2939,12 @@ toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags, int i ...@@ -2939,17 +2939,12 @@ toku_txn_begin(DB_ENV *env, DB_TXN * stxn, DB_TXN ** txn, u_int32_t flags, int i
db_txn_struct_i(result)->iso = child_isolation; db_txn_struct_i(result)->iso = child_isolation;
toku_list_init(&db_txn_struct_i(result)->dbs_that_must_close_before_abort); toku_list_init(&db_txn_struct_i(result)->dbs_that_must_close_before_abort);
int r; // we used to initialize the transaction's lth here.
if (env->i->open_flags & DB_INIT_LOCK && !stxn) { // Now we initialize the lth only if the transaction needs the lth,
r = toku_lth_create(&db_txn_struct_i(result)->lth); // in toku_txn_add_lt. If this transaction never does anything
if (r!=0) { // that requires using a lock tree, then the lth is never
#if !TOKUDB_NATIVE_H // created.
toku_free(db_txn_struct_i(result)); int r = 0;
#endif
toku_free(result);
return r;
}
}
//r = toku_logger_txn_begin(stxn ? db_txn_struct_i(stxn)->tokutxn : 0, &db_txn_struct_i(result)->tokutxn, env->i->logger); //r = toku_logger_txn_begin(stxn ? db_txn_struct_i(stxn)->tokutxn : 0, &db_txn_struct_i(result)->tokutxn, env->i->logger);
TXN_SNAPSHOT_TYPE snapshot_type; TXN_SNAPSHOT_TYPE snapshot_type;
...@@ -4536,7 +4531,13 @@ toku_txn_add_lt(DB_TXN* txn, toku_lock_tree* lt) { ...@@ -4536,7 +4531,13 @@ toku_txn_add_lt(DB_TXN* txn, toku_lock_tree* lt) {
int r = ENOSYS; int r = ENOSYS;
assert(txn && lt); assert(txn && lt);
toku_lth* lth = db_txn_struct_i(txn)->lth; toku_lth* lth = db_txn_struct_i(txn)->lth;
assert(lth); // we used to initialize the transaction's lth during begin.
// Now we initialize the lth only if the transaction needs the lth, here
if (!lth) {
r = toku_lth_create(&db_txn_struct_i(txn)->lth);
assert_zero(r);
lth = db_txn_struct_i(txn)->lth;
}
toku_lock_tree* find = toku_lth_find(lth, lt); toku_lock_tree* find = toku_lth_find(lth, lt);
if (find) { if (find) {
......
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