Commit 92b65990 authored by Yoni Fogel's avatar Yoni Fogel

addresses #2149 refs[t:2149] Add extra test for open db handles in

ENV->db(rename|remove) to prevent race conditions in the future.

git-svn-id: file:///svn/toku/tokudb.2037b@15658 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3d6a94c2
...@@ -3982,6 +3982,9 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna ...@@ -3982,6 +3982,9 @@ toku_env_dbremove(DB_ENV * env, DB_TXN *txn, const char *fname, const char *dbna
r = toku_brt_remove_on_commit(db_txn_struct_i(child)->tokutxn, r = toku_brt_remove_on_commit(db_txn_struct_i(child)->tokutxn,
&iname_dbt, &iname_within_cwd_dbt); &iname_dbt, &iname_within_cwd_dbt);
assert(r==0); assert(r==0);
//Now that we have a writelock on dname, verify that there are still no handles open. (to prevent race conditions)
if (r==0 && env_is_db_with_dname_open(env, dname))
r = toku_ydb_do_error(env, EINVAL, "Cannot remove dictionary with an open handle.\n");
} }
else { else {
r = toku_brt_remove_now(env->i->cachetable, &iname_dbt, &iname_within_cwd_dbt); r = toku_brt_remove_now(env->i->cachetable, &iname_dbt, &iname_within_cwd_dbt);
...@@ -4089,6 +4092,11 @@ toku_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbnam ...@@ -4089,6 +4092,11 @@ toku_env_dbrename(DB_ENV *env, DB_TXN *txn, const char *fname, const char *dbnam
r = toku_db_del(env->i->directory, child, &old_dname_dbt, DB_DELETE_ANY); r = toku_db_del(env->i->directory, child, &old_dname_dbt, DB_DELETE_ANY);
if (r == 0) if (r == 0)
r = toku_db_put(env->i->directory, child, &new_dname_dbt, &iname_dbt, DB_YESOVERWRITE); r = toku_db_put(env->i->directory, child, &new_dname_dbt, &iname_dbt, DB_YESOVERWRITE);
//Now that we have writelocks on both dnames, verify that there are still no handles open. (to prevent race conditions)
if (r==0 && env_is_db_with_dname_open(env, dname))
r = toku_ydb_do_error(env, EINVAL, "Cannot rename dictionary with an open handle.\n");
if (r==0 && env_is_db_with_dname_open(env, newname))
r = toku_ydb_do_error(env, EINVAL, "Cannot rename dictionary; Dictionary with target name has an open handle.\n");
} }
} }
......
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