summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2018-09-05 14:44:07 +0400
committerSergei Golubchik <serg@mariadb.org>2018-09-11 23:21:27 +0200
commitb835a12104659c0c1a8c24f57e3b6673450cda75 (patch)
treec8ba0ab247348572f7a10b4a522d8d8c130e3654
parentc54d2c820fb7e47a5bc5582b66da38ae12b55620 (diff)
downloadmariadb-git-b835a12104659c0c1a8c24f57e3b6673450cda75.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.
-rw-r--r--sql/table_cache.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index bb5258da27b..699f720297a 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);
}