Yet less TDC hash lookups
Let auto repair table and truncate table routines flush TABLE_SHARE directly. Part of MDEV-17882 - Cleanup refresh version
This commit is contained in:
parent
7a947614fb
commit
4197014ba0
@ -2942,9 +2942,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
|
||||
result= FALSE;
|
||||
}
|
||||
|
||||
tdc_release_share(share);
|
||||
/* Remove the repaired share from the table cache. */
|
||||
tdc_remove_table(thd, table_list->db.str, table_list->table_name.str);
|
||||
tdc_remove_referenced_share(thd, share);
|
||||
end_free:
|
||||
my_free(entry);
|
||||
return result;
|
||||
|
@ -336,7 +336,10 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
|
||||
}
|
||||
#endif
|
||||
|
||||
tdc_release_share(share);
|
||||
if (!versioned)
|
||||
tdc_remove_referenced_share(thd, share);
|
||||
else
|
||||
tdc_release_share(share);
|
||||
|
||||
if (hton == view_pseudo_hton)
|
||||
{
|
||||
@ -372,12 +375,6 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
|
||||
if (*hton_can_recreate)
|
||||
close_all_tables_for_name(thd, table->s, HA_EXTRA_NOT_USED, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Table is already locked exclusively. Remove cached instances. */
|
||||
tdc_remove_table(thd, table_ref->db.str, table_ref->table_name.str);
|
||||
}
|
||||
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
|
@ -996,6 +996,20 @@ void tdc_release_share(TABLE_SHARE *share)
|
||||
}
|
||||
|
||||
|
||||
void tdc_remove_referenced_share(THD *thd, TABLE_SHARE *share)
|
||||
{
|
||||
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, share->db.str,
|
||||
share->table_name.str,
|
||||
MDL_EXCLUSIVE));
|
||||
share->tdc->flush_unused(false);
|
||||
mysql_mutex_lock(&share->tdc->LOCK_table_share);
|
||||
share->tdc->wait_for_refs(1);
|
||||
DBUG_ASSERT(share->tdc->all_tables.is_empty());
|
||||
share->tdc->ref_count--;
|
||||
tdc_delete_share_from_hash(share->tdc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Removes all TABLE instances and corresponding TABLE_SHARE
|
||||
|
||||
@ -1009,7 +1023,6 @@ void tdc_release_share(TABLE_SHARE *share)
|
||||
|
||||
void tdc_remove_table(THD *thd, const char *db, const char *table_name)
|
||||
{
|
||||
Share_free_tables::List purge_tables;
|
||||
TDC_element *element;
|
||||
DBUG_ENTER("tdc_remove_table");
|
||||
DBUG_PRINT("enter", ("name: %s", table_name));
|
||||
@ -1042,18 +1055,10 @@ void tdc_remove_table(THD *thd, const char *db, const char *table_name)
|
||||
mysql_mutex_unlock(&LOCK_unused_shares);
|
||||
|
||||
element->ref_count++;
|
||||
|
||||
tc_remove_all_unused_tables(element, &purge_tables);
|
||||
mysql_mutex_unlock(&element->LOCK_table_share);
|
||||
|
||||
while (auto table= purge_tables.pop_front())
|
||||
intern_close_table(table);
|
||||
|
||||
mysql_mutex_lock(&element->LOCK_table_share);
|
||||
element->wait_for_refs(1);
|
||||
DBUG_ASSERT(element->all_tables.is_empty());
|
||||
element->ref_count--;
|
||||
tdc_delete_share_from_hash(element);
|
||||
/* We have to relock the mutex to avoid code duplication. Sigh. */
|
||||
tdc_remove_referenced_share(thd, element->share);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ int tdc_share_is_cached(THD *thd, const char *db, const char *table_name);
|
||||
extern TABLE_SHARE *tdc_acquire_share(THD *thd, TABLE_LIST *tl, uint flags,
|
||||
TABLE **out_table= 0);
|
||||
extern void tdc_release_share(TABLE_SHARE *share);
|
||||
void tdc_remove_referenced_share(THD *thd, TABLE_SHARE *share);
|
||||
void tdc_remove_table(THD *thd, const char *db, const char *table_name);
|
||||
|
||||
extern int tdc_wait_for_old_version(THD *thd, const char *db,
|
||||
|
Loading…
x
Reference in New Issue
Block a user