Commit 0aa2bc7a authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19445/MDEV-16678 fixup: Acquire proper MDL on innodb_ft_aux_table

In commit 2647fd10 (MDEV-19445)
we fixed a race condition around the INFORMATION_SCHEMA tables
that access the table identified by the global variable
innodb_ft_aux_table. Thanks to MDEV-16678 we could fix it
even better by using MDL instead of the InnoDB dict_sys latches.
parent e305493b
...@@ -2401,21 +2401,17 @@ i_s_fts_deleted_generic_fill( ...@@ -2401,21 +2401,17 @@ i_s_fts_deleted_generic_fill(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* Prevent DROP of the internal tables for fulltext indexes. MDL_ticket* mdl_ticket = nullptr;
FIXME: acquire DDL-blocking MDL on the user table name! */
dict_sys.freeze();
user_table = dict_table_open_on_id( user_table = dict_table_open_on_id(
innodb_ft_aux_table_id, FALSE, DICT_TABLE_OP_NORMAL); innodb_ft_aux_table_id, false, DICT_TABLE_OP_NORMAL,
thd, &mdl_ticket);
if (!user_table) { if (!user_table) {
func_exit:
dict_sys.unfreeze();
DBUG_RETURN(0); DBUG_RETURN(0);
} else if (!dict_table_has_fts_index(user_table) } else if (!dict_table_has_fts_index(user_table)
|| !user_table->is_readable()) { || !user_table->is_readable()) {
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
goto func_exit; DBUG_RETURN(0);
} }
deleted = fts_doc_ids_create(); deleted = fts_doc_ids_create();
...@@ -2429,9 +2425,7 @@ i_s_fts_deleted_generic_fill( ...@@ -2429,9 +2425,7 @@ i_s_fts_deleted_generic_fill(
fts_table_fetch_doc_ids(trx, &fts_table, deleted); fts_table_fetch_doc_ids(trx, &fts_table, deleted);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
dict_sys.unfreeze();
trx->free(); trx->free();
...@@ -2778,22 +2772,18 @@ i_s_fts_index_cache_fill( ...@@ -2778,22 +2772,18 @@ i_s_fts_index_cache_fill(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* Prevent DROP of the internal tables for fulltext indexes. MDL_ticket* mdl_ticket = nullptr;
FIXME: acquire DDL-blocking MDL on the user table name! */
dict_sys.freeze();
user_table = dict_table_open_on_id( user_table = dict_table_open_on_id(
innodb_ft_aux_table_id, FALSE, DICT_TABLE_OP_NORMAL); innodb_ft_aux_table_id, false, DICT_TABLE_OP_NORMAL,
thd, &mdl_ticket);
if (!user_table) { if (!user_table) {
no_fts:
dict_sys.unfreeze();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!user_table->fts || !user_table->fts->cache) { if (!user_table->fts || !user_table->fts->cache) {
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
goto no_fts; DBUG_RETURN(0);
} }
cache = user_table->fts->cache; cache = user_table->fts->cache;
...@@ -2817,8 +2807,7 @@ i_s_fts_index_cache_fill( ...@@ -2817,8 +2807,7 @@ i_s_fts_index_cache_fill(
} }
mysql_mutex_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
dict_sys.unfreeze();
DBUG_RETURN(ret); DBUG_RETURN(ret);
} }
...@@ -3226,15 +3215,12 @@ i_s_fts_index_table_fill( ...@@ -3226,15 +3215,12 @@ i_s_fts_index_table_fill(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* Prevent DROP of the internal tables for fulltext indexes. MDL_ticket* mdl_ticket = nullptr;
FIXME: acquire DDL-blocking MDL on the user table name! */
dict_sys.freeze();
user_table = dict_table_open_on_id( user_table = dict_table_open_on_id(
innodb_ft_aux_table_id, FALSE, DICT_TABLE_OP_NORMAL); innodb_ft_aux_table_id, false, DICT_TABLE_OP_NORMAL,
thd, &mdl_ticket);
if (!user_table) { if (!user_table) {
dict_sys.unfreeze();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -3252,9 +3238,7 @@ i_s_fts_index_table_fill( ...@@ -3252,9 +3238,7 @@ i_s_fts_index_table_fill(
} }
} }
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
dict_sys.unfreeze();
ut_free(conv_str.f_str); ut_free(conv_str.f_str);
...@@ -3380,22 +3364,18 @@ i_s_fts_config_fill( ...@@ -3380,22 +3364,18 @@ i_s_fts_config_fill(
RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str); RETURN_IF_INNODB_NOT_STARTED(tables->schema_table_name.str);
/* Prevent DROP of the internal tables for fulltext indexes. MDL_ticket* mdl_ticket = nullptr;
FIXME: acquire DDL-blocking MDL on the user table name! */
dict_sys.freeze();
user_table = dict_table_open_on_id( user_table = dict_table_open_on_id(
innodb_ft_aux_table_id, FALSE, DICT_TABLE_OP_NORMAL); innodb_ft_aux_table_id, false, DICT_TABLE_OP_NORMAL,
thd, &mdl_ticket);
if (!user_table) { if (!user_table) {
no_fts:
dict_sys.unfreeze();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (!dict_table_has_fts_index(user_table)) { if (!dict_table_has_fts_index(user_table)) {
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
goto no_fts; DBUG_RETURN(0);
} }
fields = table->field; fields = table->field;
...@@ -3451,9 +3431,7 @@ i_s_fts_config_fill( ...@@ -3451,9 +3431,7 @@ i_s_fts_config_fill(
fts_sql_commit(trx); fts_sql_commit(trx);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, false, false, thd, mdl_ticket);
dict_sys.unfreeze();
trx->free(); trx->free();
......
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