MDEV-16773 - Assertion failed in tdc_remove_table

This assertion fails in thread that removes all table instances for
particular table from table cache (e.g. "DROP TABLE") while another
thread evicts table instance of the same table from table cache
concurrently.

After "MDEV-10296 - Multi-instance table cache" there is a gap in
eviction code of tc_add_table() between removing table from free_tables
and all_tables not protected by any mutexes.

This is now valid table cache state, however assertion wasn't amended
along with original patch. Moved assertion down, after waiting for such
table instances to get closed.
This commit is contained in:
Sergey Vojtovich 2018-09-05 14:44:07 +04:00
parent 4d991abd4f
commit e76c4c06f1

View file

@ -1123,11 +1123,10 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
All_share_tables_list::Iterator it(element->all_tables);
while ((table= it++))
{
my_refs++;
DBUG_ASSERT(table->in_use == thd);
if (table->in_use == thd)
my_refs++;
}
}
DBUG_ASSERT(element->all_tables.is_empty() || remove_type != TDC_RT_REMOVE_ALL);
mysql_mutex_unlock(&element->LOCK_table_share);
while ((table= purge_tables.pop_front()))
@ -1159,6 +1158,17 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
mysql_mutex_lock(&element->LOCK_table_share);
while (element->ref_count > my_refs)
mysql_cond_wait(&element->COND_release, &element->LOCK_table_share);
DBUG_ASSERT(element->all_tables.is_empty() ||
remove_type != TDC_RT_REMOVE_ALL);
#ifndef DBUG_OFF
if (remove_type == TDC_RT_REMOVE_NOT_OWN ||
remove_type == TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE)
{
All_share_tables_list::Iterator it(element->all_tables);
while ((table= it++))
DBUG_ASSERT(table->in_use == thd);
}
#endif
mysql_mutex_unlock(&element->LOCK_table_share);
}