Skip to content

Commit

Permalink
Move wait_for_mdl_deadlock_detector() call to tc_remove_table()
Browse files Browse the repository at this point in the history
As a side effect tc_remove_all_unused_tables() has to call
tc_wait_for_mdl_deadlock_detector() once per TABLE object now, while it called
it only once before. This should be acceptable since actual wait will still be
performed only once. It only adds redundant checks for all_tables_refs.
  • Loading branch information
Sergey Vojtovich committed Jun 1, 2016
1 parent 41dc2fc commit d6d4011
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sql/table_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ static void tc_wait_for_mdl_deadlock_detector(TDC_element *element)

static void tc_remove_table(TABLE *table)
{
mysql_mutex_assert_owner(&table->s->tdc->LOCK_table_share);
tc_wait_for_mdl_deadlock_detector(table->s->tdc);
my_atomic_add32_explicit(&tc_count, -1, MY_MEMORY_ORDER_RELAXED);
table->s->tdc->all_tables.remove(table);
}
Expand All @@ -171,7 +173,6 @@ static void tc_remove_all_unused_tables(TDC_element *element,
{
TABLE *table;

tc_wait_for_mdl_deadlock_detector(element);
/*
Mark share flushed in order to ensure that it gets
automatically deleted once it is no longer referenced.
Expand Down Expand Up @@ -317,7 +318,6 @@ void tc_add_table(THD *thd, TABLE *table)
TABLE *entry;
mysql_mutex_lock(&element->LOCK_table_share);
lf_hash_search_unpin(thd->tdc_hash_pins);
tc_wait_for_mdl_deadlock_detector(element);

/*
It may happen that oldest table was acquired meanwhile. In this case
Expand Down Expand Up @@ -425,7 +425,6 @@ bool tc_release_table(TABLE *table)
return false;

purge:
tc_wait_for_mdl_deadlock_detector(table->s->tdc);
tc_remove_table(table);
mysql_mutex_unlock(&table->s->tdc->LOCK_table_share);
table->in_use= 0;
Expand Down

0 comments on commit d6d4011

Please sign in to comment.