From 0e1c0e15d367680d7540b605c27f673a891b37f7 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 13 Nov 2019 13:40:50 +0530 Subject: MDEV-16678 Use MDL for innodb background threads instead of dict_operation_lock - Remove index_fts_syncing and its related functions --- .../suite/innodb/r/row_format_redundant.result | 2 +- storage/innobase/fts/fts0fts.cc | 23 ------------- storage/innobase/handler/ha_innodb.cc | 30 ----------------- storage/innobase/handler/handler0alter.cc | 38 ---------------------- storage/innobase/include/dict0dict.ic | 22 ------------- storage/innobase/include/dict0mem.h | 3 -- storage/innobase/row/row0mysql.cc | 13 -------- 7 files changed, 1 insertion(+), 130 deletions(-) diff --git a/mysql-test/suite/innodb/r/row_format_redundant.result b/mysql-test/suite/innodb/r/row_format_redundant.result index 2df6eaceb34..0b42d297395 100644 --- a/mysql-test/suite/innodb/r/row_format_redundant.result +++ b/mysql-test/suite/innodb/r/row_format_redundant.result @@ -76,7 +76,7 @@ DROP TABLE t1; Warnings: Warning 1932 Table 'test.t1' doesn't exist in engine DROP TABLE t2,t3; -FOUND 50 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b/ in mysqld.1.err +FOUND 49 /\[ERROR\] InnoDB: Table `test`\.`t1` in InnoDB data dictionary contains invalid flags\. SYS_TABLES\.TYPE=1 SYS_TABLES\.MIX_LEN=511\b/ in mysqld.1.err # restart ib_buffer_pool ib_logfile0 diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 7af4ab1a84c..fec69025152 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -846,21 +846,11 @@ fts_drop_index( err = fts_drop_index_tables(trx, index); - while (index->index_fts_syncing - && !trx_is_interrupted(trx)) { - DICT_BG_YIELD(trx); - } - fts_free(table); return(err); } - while (index->index_fts_syncing - && !trx_is_interrupted(trx)) { - DICT_BG_YIELD(trx); - } - current_doc_id = table->fts->cache->next_doc_id; first_doc_id = table->fts->cache->first_doc_id; fts_cache_clear(table->fts->cache); @@ -877,10 +867,6 @@ fts_drop_index( index_cache = fts_find_index_cache(cache, index); if (index_cache != NULL) { - while (index->index_fts_syncing - && !trx_is_interrupted(trx)) { - DICT_BG_YIELD(trx); - } if (index_cache->words) { fts_words_free(index_cache->words); rbt_free(index_cache->words); @@ -4318,8 +4304,6 @@ begin_sync: DBUG_EXECUTE_IF("fts_instrument_sync_before_syncing", os_thread_sleep(300000);); - index_cache->index->index_fts_syncing = true; - error = fts_sync_index(sync, index_cache); if (error != DB_SUCCESS) { @@ -4357,13 +4341,6 @@ end_sync: } rw_lock_x_lock(&cache->lock); - /* Clear fts syncing flags of any indexes in case sync is - interrupted */ - for (i = 0; i < ib_vector_size(cache->indexes); ++i) { - static_cast( - ib_vector_get(cache->indexes, i)) - ->index->index_fts_syncing = false; - } sync->interrupted = false; sync->in_progress = false; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 6b12dd7572d..06ce6152c60 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -13000,35 +13000,6 @@ innobase_rename_table( row_mysql_lock_data_dictionary(trx); } - dict_table_t* table = dict_table_open_on_name( - norm_from, TRUE, FALSE, DICT_ERR_IGNORE_FK_NOKEY); - - /* Since DICT_BG_YIELD has sleep for 250 milliseconds, - Convert lock_wait_timeout unit from second to 250 milliseconds */ - long int lock_wait_timeout = thd_lock_wait_timeout(trx->mysql_thd) * 4; - if (table != NULL) { - for (dict_index_t* index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - - if (index->type & DICT_FTS) { - /* Found */ - while (index->index_fts_syncing - && !trx_is_interrupted(trx) - && (lock_wait_timeout--) > 0) { - DICT_BG_YIELD(trx); - } - } - } - dict_table_close(table, TRUE, FALSE); - } - - /* FTS sync is in progress. We shall timeout this operation */ - if (lock_wait_timeout < 0) { - error = DB_LOCK_WAIT_TIMEOUT; - goto func_exit; - } - error = row_rename_table_for_mysql(norm_from, norm_to, trx, commit, use_fk); @@ -13080,7 +13051,6 @@ innobase_rename_table( } } -func_exit: if (commit) { row_mysql_unlock_data_dictionary(trx); } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index b794e5ccfd3..78dd9da4165 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10840,44 +10840,6 @@ ha_innobase::commit_inplace_alter_table( DICT_BG_YIELD(trx); } - /* Make a concurrent Drop fts Index to wait until sync of that - fts index is happening in the background */ - for (int retry_count = 0;;) { - bool retry = false; - - for (inplace_alter_handler_ctx** pctx = ctx_array; - *pctx; pctx++) { - ha_innobase_inplace_ctx* ctx - = static_cast(*pctx); - DBUG_ASSERT(new_clustered == ctx->need_rebuild()); - - if (dict_fts_index_syncing(ctx->old_table)) { - retry = true; - break; - } - - if (new_clustered && dict_fts_index_syncing(ctx->new_table)) { - retry = true; - break; - } - } - - if (!retry) { - break; - } - - /* Print a message if waiting for a long time. */ - if (retry_count < 100) { - retry_count++; - } else { - ib::info() << "Drop index waiting for background sync" - " to finish"; - retry_count = 0; - } - - DICT_BG_YIELD(trx); - } - /* Apply the changes to the data dictionary tables, for all partitions. */ diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index b6d15f28a69..e24085ecefe 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -705,28 +705,6 @@ dict_tf_to_sys_tables_type( return(type); } -/*********************************************************************//** -Returns true if the particular FTS index in the table is still syncing -in the background, false otherwise. -@param [in] table Table containing FTS index -@return True if sync of fts index is still going in the background */ -UNIV_INLINE -bool -dict_fts_index_syncing( - dict_table_t* table) -{ - dict_index_t* index; - - for (index = dict_table_get_first_index(table); - index != NULL; - index = dict_table_get_next_index(index)) { - if (index->index_fts_syncing) { - return(true); - } - } - return(false); -} - /********************************************************************//** Gets the number of fields in the internal representation of an index, including fields added by the dictionary system. diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 336834cda95..c4a887ed6bb 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -994,9 +994,6 @@ struct dict_index_t { bool has_new_v_col; /*!< whether it has a newly added virtual column in ALTER */ - bool index_fts_syncing;/*!< Whether the fts index is - still syncing in the background; - FIXME: remove this and use MDL */ UT_LIST_NODE_T(dict_index_t) indexes;/*!< list of indexes of the table */ #ifdef BTR_CUR_ADAPT diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index b2f51fdd9f4..e8af45f79b7 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3374,19 +3374,6 @@ row_drop_table_for_mysql( table records yet. Thus it is safe to release and reacquire the data dictionary latches. */ if (table->fts) { - ut_ad(!table->fts->add_wq); - ut_ad(lock_trx_has_sys_table_locks(trx) == 0); - - for (;;) { - bool retry = false; - if (dict_fts_index_syncing(table)) { - retry = true; - } - if (!retry) { - break; - } - DICT_BG_YIELD(trx); - } row_mysql_unlock_data_dictionary(trx); fts_optimize_remove_table(table); row_mysql_lock_data_dictionary(trx); -- cgit v1.2.1