From 71064cbe5d2689e339a5499086fe7f9b5f39e0a1 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 28 Mar 2014 11:30:10 +0400 Subject: MDEV-5964 - main.mdev-504 unveils assertion failure in TABLE_SHARE::visit_subgraph tc_acquire_table() is not ready to update TABLE::in_use without mutex: thr1: table= free_tables.pop_front(); // table->in_use is 0 thr2: tdc_remove_table(); thr2: find_deadlock(); // assert(table->in_use != 0) thr1: table->in_use= thd; Protect update of TABLE::in_use by LOCK_table_share. --- sql/table_cache.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql/table_cache.cc') diff --git a/sql/table_cache.cc b/sql/table_cache.cc index af22c67044b..8b768240b4f 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -332,8 +332,6 @@ static TABLE *tc_acquire_table(THD *thd, TABLE_SHARE *share) mysql_mutex_lock(&share->tdc.LOCK_table_share); table= share->tdc.free_tables.pop_front(); - mysql_mutex_unlock(&share->tdc.LOCK_table_share); - if (table) { DBUG_ASSERT(!table->in_use); @@ -343,6 +341,7 @@ static TABLE *tc_acquire_table(THD *thd, TABLE_SHARE *share) /* The children must be detached from the table. */ DBUG_ASSERT(!table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN)); } + mysql_mutex_unlock(&share->tdc.LOCK_table_share); return table; } -- cgit v1.2.1