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

[t:3212], fix race condition

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@27537 c7de825b-a66e-492c-adef-691d508d4ae1
parent cbbaaf91
...@@ -6585,6 +6585,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6585,6 +6585,7 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
lc.ha = this; lc.ha = this;
loader_error = 0; loader_error = 0;
bool rw_lock_taken = false; bool rw_lock_taken = false;
bool modified_DBs = false;
for (u_int32_t i = 0; i < MAX_KEY+1; i++) { for (u_int32_t i = 0; i < MAX_KEY+1; i++) {
mult_put_flags[i] = DB_YESOVERWRITE; mult_put_flags[i] = DB_YESOVERWRITE;
mult_dbt_flags[i] = DB_DBT_REALLOC; mult_dbt_flags[i] = DB_DBT_REALLOC;
...@@ -6634,7 +6635,15 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6634,7 +6635,15 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
// they go to the end of share->key_file // they go to the end of share->key_file
// //
creating_hot_index = use_hot_index && num_of_keys == 1 && (key_info[0].flags & HA_NOSAME) == 0; creating_hot_index = use_hot_index && num_of_keys == 1 && (key_info[0].flags & HA_NOSAME) == 0;
if (use_hot_index && (share->num_DBs > curr_num_DBs)) {
//
// already have hot index in progress, get out
//
error = HA_ERR_INTERNAL_ERROR;
goto cleanup;
}
curr_index = curr_num_DBs; curr_index = curr_num_DBs;
modified_DBs = true;
for (uint i = 0; i < num_of_keys; i++, curr_index++) { for (uint i = 0; i < num_of_keys; i++, curr_index++) {
if (key_info[i].flags & HA_CLUSTERING) { if (key_info[i].flags & HA_CLUSTERING) {
set_key_filter( set_key_filter(
...@@ -6673,14 +6682,6 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6673,14 +6682,6 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
} }
if (creating_hot_index) { if (creating_hot_index) {
if (share->num_DBs > curr_num_DBs) {
//
// already have hot index in progress, get out
//
error = HA_ERR_INTERNAL_ERROR;
rw_unlock(&share->num_DBs_lock);
goto cleanup;
}
share->num_DBs++; share->num_DBs++;
incremented_numDBs = true; incremented_numDBs = true;
error = db_env->create_indexer( error = db_env->create_indexer(
...@@ -6847,11 +6848,6 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6847,11 +6848,6 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
thd_proc_info(thd, status_msg); thd_proc_info(thd, status_msg);
indexer->abort(indexer); indexer->abort(indexer);
} }
if (error) { // 3144
curr_index = curr_num_DBs;
for (uint i = 0; i < num_of_keys; i++, curr_index++)
reset_key_and_col_info(&share->kc_info, curr_index);
}
if (txn) { if (txn) {
if (error) { if (error) {
// //
...@@ -6862,15 +6858,21 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) { ...@@ -6862,15 +6858,21 @@ int ha_tokudb::add_index(TABLE *table_arg, KEY *key_info, uint num_of_keys) {
rw_wrlock(&share->num_DBs_lock); rw_wrlock(&share->num_DBs_lock);
share->num_DBs--; share->num_DBs--;
} }
curr_index = curr_num_DBs; if (modified_DBs) {
for (uint i = 0; i < num_of_keys; i++, curr_index++) { curr_index = curr_num_DBs; //3144
if (share->key_file[curr_index]) { for (uint i = 0; i < num_of_keys; i++, curr_index++) {
int r = share->key_file[curr_index]->close( reset_key_and_col_info(&share->kc_info, curr_index);
share->key_file[curr_index], }
0 curr_index = curr_num_DBs;
); for (uint i = 0; i < num_of_keys; i++, curr_index++) {
assert(r==0); if (share->key_file[curr_index]) {
share->key_file[curr_index] = NULL; int r = share->key_file[curr_index]->close(
share->key_file[curr_index],
0
);
assert(r==0);
share->key_file[curr_index] = NULL;
}
} }
} }
abort_txn(txn); abort_txn(txn);
......
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