diff options
author | Sergey Vojtovich <svoj@mariadb.org> | 2018-09-05 14:44:07 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2018-09-10 18:31:14 +0400 |
commit | e76c4c06f18c0d09a296a60b6d00332620e98e53 (patch) | |
tree | 57b4fb70c0a60da1e99801a797e2cbe9448667cb /sql | |
parent | 4d991abd4fc7f60e758ec46301b0dd2bee71245c (diff) | |
download | mariadb-git-e76c4c06f18c0d09a296a60b6d00332620e98e53.tar.gz |
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.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/table_cache.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 7dfd1c2ac8e..7be5f5f771b 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -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); } |