Commit 117f4c12 authored by Rik Prohaska's avatar Rik Prohaska

DB-832 fix race with dbtxn initialization and live txn iterator

parent 868c5872
......@@ -2490,23 +2490,21 @@ struct iter_txns_callback_extra {
};
static int iter_txns_callback(TOKUTXN txn, void *extra) {
int r = 0;
iter_txns_callback_extra *info =
reinterpret_cast<iter_txns_callback_extra *>(extra);
DB_TXN *dbtxn = toku_txn_get_container_db_txn(txn);
invariant_notnull(dbtxn);
if (db_txn_struct_i(dbtxn)->tokutxn == txn) { // make sure that the dbtxn is fully initialized
toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex);
toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock);
toku_mutex_lock(&db_txn_struct_i(dbtxn)->txn_mutex);
toku_pthread_rwlock_rdlock(&info->env->i->open_dbs_rwlock);
iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map);
const int r = info->callback(dbtxn,
iter_txn_row_locks_callback,
&e,
info->extra);
iter_txn_row_locks_callback_extra e(info->env, &db_txn_struct_i(dbtxn)->lt_map);
r = info->callback(dbtxn, iter_txn_row_locks_callback, &e, info->extra);
toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock);
toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex);
toku_pthread_rwlock_rdunlock(&info->env->i->open_dbs_rwlock);
toku_mutex_unlock(&db_txn_struct_i(dbtxn)->txn_mutex);
}
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