Commit d46b4cfc authored by Rich Prohaska's avatar Rich Prohaska

#69 run create unique index with MDL shared no write (not hot WRT writes)

parent 3b339f31
drop table if exists t;
create table t (id int auto_increment primary key, x int);
create unique index x on t (x);
drop table t;
# verify that create unique index is not a hot operation.
# in tokudb_add_index assert that the table MDL >= shared no write.
source include/have_tokudb.inc;
source include/have_debug.inc;
disable_warnings;
drop table if exists t;
enable_warnings;
create table t (id int auto_increment primary key, x int);
create unique index x on t (x);
drop table t;
......@@ -3470,6 +3470,8 @@ int ha_tokudb::end_bulk_insert() {
return end_bulk_insert( false );
}
volatile int ha_tokudb_is_index_unique_wait = 0; // debug
int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_info) {
int error;
DBC* tmp_cursor1 = NULL;
......@@ -3614,6 +3616,7 @@ int ha_tokudb::is_index_unique(bool* is_unique, DB_TXN* txn, DB* db, KEY* key_in
error = 0;
cleanup:
while (ha_tokudb_is_index_unique_wait) sleep(1); // debug
if (tmp_cursor1) {
tmp_cursor1->c_close(tmp_cursor1);
tmp_cursor1 = NULL;
......@@ -7813,6 +7816,7 @@ int ha_tokudb::tokudb_add_index(
indexer = NULL;
}
else {
DBUG_ASSERT(table->mdl_ticket->get_type() >= MDL_SHARED_NO_WRITE);
rw_unlock(&share->num_DBs_lock);
rw_lock_taken = false;
prelocked_right_range_size = 0;
......
......@@ -312,8 +312,10 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *alt
// someday, allow multiple hot indexes via alter table add key. don't forget to change the store_lock function.
// for now, hot indexing is only supported via session variable with the create index sql command
if (ha_alter_info->index_add_count == 1 && ha_alter_info->index_drop_count == 0 &&
get_create_index_online(thd) && thd_sql_command(thd) == SQLCOM_CREATE_INDEX) {
if (ha_alter_info->index_add_count == 1 && ha_alter_info->index_drop_count == 0 && // only one add or drop
ctx->handler_flags == Alter_inplace_info::ADD_INDEX && // must be add index not add unique index
thd_sql_command(thd) == SQLCOM_CREATE_INDEX && // must be a create index command
get_create_index_online(thd)) { // must be enabled
// external_lock set WRITE_ALLOW_WRITE which allows writes concurrent with the index creation
result = HA_ALTER_INPLACE_NO_LOCK_AFTER_PREPARE;
}
......
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