MDEV-13266: Race condition in ANALYZE TABLE / statistics collection
Fixing a race condition while collecting the engine independent statistics. Thread1> 1) start running "ANALYZE TABLE t PERISTENT FOR COLUMNS (..) INDEXES ($list)" 2) Walk through $list and save it in TABLE::keys_in_use_for_query 3) Close/re-open tables Thread2> 1) Make some use of table t. This involves taking table t from the table cache, and putting it back (with TABLE::keys_in_use_for_query reset to 0) Thread1> continue collecting EITS stats. Since TABLE::keys_in_use_for_query is set to 0 we will not collect statistics for indexes in $list.
This commit is contained in:
parent
b9f177f66a
commit
06b245f768
@ -769,31 +769,6 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
(table->table->s->table_category == TABLE_CATEGORY_USER &&
|
||||
(get_use_stat_tables_mode(thd) > NEVER ||
|
||||
lex->with_persistent_for_clause));
|
||||
|
||||
|
||||
if (!lex->index_list)
|
||||
{
|
||||
tab->keys_in_use_for_query.init(tab->s->keys);
|
||||
}
|
||||
else
|
||||
{
|
||||
int pos;
|
||||
LEX_STRING *index_name;
|
||||
List_iterator_fast<LEX_STRING> it(*lex->index_list);
|
||||
|
||||
tab->keys_in_use_for_query.clear_all();
|
||||
while ((index_name= it++))
|
||||
{
|
||||
if (tab->s->keynames.type_names == 0 ||
|
||||
(pos= find_type(&tab->s->keynames, index_name->str,
|
||||
index_name->length, 1)) <= 0)
|
||||
{
|
||||
compl_result_code= result_code= HA_ADMIN_INVALID;
|
||||
break;
|
||||
}
|
||||
tab->keys_in_use_for_query.set_bit(--pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result_code == HA_ADMIN_OK)
|
||||
@ -878,6 +853,27 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
|
||||
}
|
||||
tab->file->column_bitmaps_signal();
|
||||
}
|
||||
if (!lex->index_list)
|
||||
tab->keys_in_use_for_query.init(tab->s->keys);
|
||||
else
|
||||
{
|
||||
int pos;
|
||||
LEX_STRING *index_name;
|
||||
List_iterator_fast<LEX_STRING> it(*lex->index_list);
|
||||
|
||||
tab->keys_in_use_for_query.clear_all();
|
||||
while ((index_name= it++))
|
||||
{
|
||||
if (tab->s->keynames.type_names == 0 ||
|
||||
(pos= find_type(&tab->s->keynames, index_name->str,
|
||||
index_name->length, 1)) <= 0)
|
||||
{
|
||||
compl_result_code= result_code= HA_ADMIN_INVALID;
|
||||
break;
|
||||
}
|
||||
tab->keys_in_use_for_query.set_bit(--pos);
|
||||
}
|
||||
}
|
||||
if (!(compl_result_code=
|
||||
alloc_statistics_for_table(thd, table->table)) &&
|
||||
!(compl_result_code=
|
||||
|
Loading…
x
Reference in New Issue
Block a user