Commit 092834cd authored by Sergey Vojtovich's avatar Sergey Vojtovich

Removed kill_delayed_threads_for_table()

After 7fb9d649 it is used only by ALTER/DROP SERVER, which most probably
wasn't intentional as Federated never supported delayed inserts anyway.

If delayed inserts will ever become an issue with ALTER/DROP SERVER, we
should kill them by acquiring X-lock instead.

Part of MDEV-17882 - Cleanup refresh version
parent 0aa807d1
......@@ -425,7 +425,7 @@ rpl_slave_state::truncate_state_table(THD *thd)
if (!(err= open_and_lock_tables(thd, &tlist, FALSE, 0)))
{
tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED, "mysql",
rpl_gtid_slave_state_table_name.str, false);
rpl_gtid_slave_state_table_name.str);
err= tlist.table->file->ha_truncate();
if (err)
......
......@@ -1158,7 +1158,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
else if (open_for_modify || fatal_error)
{
tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
table->db.str, table->table_name.str, FALSE);
table->db.str, table->table_name.str);
/*
May be something modified. Consequently, we have to
invalidate the query cache.
......
......@@ -450,7 +450,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables,
for (TABLE_LIST *table= tables; table; table= table->next_local)
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db.str,
table->table_name.str, false);
table->table_name.str);
}
DBUG_RETURN(false);
}
......@@ -717,7 +717,7 @@ bool close_cached_connection_tables(THD *thd, LEX_CSTRING *connection)
for (TABLE_LIST *table= argument.tables; table; table= table->next_local)
res|= tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
table->db.str,
table->table_name.str, TRUE);
table->table_name.str);
/* Return true if we found any open connections */
DBUG_RETURN(res);
......@@ -846,12 +846,9 @@ close_all_tables_for_name(THD *thd, TABLE_SHARE *share,
prev= &table->next;
}
}
/* Remove the table share from the cache. */
if (skip_table == NULL)
{
/* Remove the table share from the cache. */
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name,
FALSE);
}
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table_name);
}
......@@ -1414,8 +1411,7 @@ bool wait_while_table_is_used(THD *thd, TABLE *table,
DBUG_RETURN(TRUE);
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN,
table->s->db.str, table->s->table_name.str,
FALSE);
table->s->db.str, table->s->table_name.str);
/* extra() call must come only after all instances above are closed */
if (function != HA_EXTRA_NOT_USED)
(void) table->file->extra(function);
......@@ -1456,8 +1452,7 @@ void drop_open_table(THD *thd, TABLE *table, const LEX_CSTRING *db_name,
table->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
close_thread_table(thd, &thd->open_tables);
/* Remove the table share from the table cache. */
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name->str, table_name->str,
FALSE);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db_name->str, table_name->str);
/* Remove the table from the storage engine and rm the .frm. */
quick_rm_table(thd, table_type, db_name, table_name, 0);
}
......@@ -3046,8 +3041,7 @@ static bool auto_repair_table(THD *thd, TABLE_LIST *table_list)
tdc_release_share(share);
/* Remove the repaired share from the table cache. */
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
table_list->db.str, table_list->table_name.str,
FALSE);
table_list->db.str, table_list->table_name.str);
end_free:
my_free(entry);
return result;
......@@ -3219,7 +3213,7 @@ Open_table_context::recover_from_failed_open()
break;
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db.str,
m_failed_table->table_name.str, FALSE);
m_failed_table->table_name.str);
m_thd->get_stmt_da()->clear_warning_info(m_thd->query_id);
m_thd->clear_error(); // Clear error message
......@@ -3255,7 +3249,7 @@ Open_table_context::recover_from_failed_open()
break;
tdc_remove_table(m_thd, TDC_RT_REMOVE_ALL, m_failed_table->db.str,
m_failed_table->table_name.str, FALSE);
m_failed_table->table_name.str);
result= auto_repair_table(m_thd, m_failed_table);
/*
......
......@@ -31,7 +31,7 @@
#include "sql_acl.h" // SELECT_ACL, DB_ACLS,
// acl_get, check_grant_db
#include "log_event.h" // Query_log_event
#include "sql_base.h" // lock_table_names, tdc_remove_table
#include "sql_base.h" // lock_table_names
#include "sql_handler.h" // mysql_ha_rm_tables
#include "sql_class.h"
#include <mysys_err.h>
......
......@@ -826,7 +826,7 @@ bool Sql_cmd_alter_table_truncate_partition::execute(THD *thd)
DBUG_RETURN(TRUE);
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN, first_table->db.str,
first_table->table_name.str, FALSE);
first_table->table_name.str);
partition= (ha_partition*) first_table->table->file;
/* Invoke the handler method responsible for truncating the partition. */
......
......@@ -545,7 +545,7 @@ bool flush_tables_with_read_lock(THD *thd, TABLE_LIST *all_tables)
/* Request removal of table from cache. */
tdc_remove_table(thd, TDC_RT_REMOVE_UNUSED,
table_list->db.str,
table_list->table_name.str, FALSE);
table_list->table_name.str);
/* Reset ticket to satisfy asserts in open_tables(). */
table_list->mdl_request.ticket= NULL;
}
......
......@@ -287,7 +287,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, const LEX_CSTRING *new_db,
{
DBUG_ASSERT(!thd->locked_tables_mode);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
ren_table->db.str, ren_table->table_name.str, false);
ren_table->db.str, ren_table->table_name.str);
if (hton != view_pseudo_hton)
{
......
......@@ -2470,8 +2470,8 @@ int mysql_rm_table_no_locks(THD *thd, TABLE_LIST *tables, bool if_exists,
table->table= 0;
}
else
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db.str, table->table_name.str,
false);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table->db.str,
table->table_name.str);
/* Check that we have an exclusive lock on the table to be dropped. */
DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->db.str,
......@@ -7626,8 +7626,7 @@ static bool mysql_inplace_alter_table(THD *thd,
goto cleanup;
tdc_remove_table(thd, TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE,
table->s->db.str, table->s->table_name.str,
false);
table->s->db.str, table->s->table_name.str);
}
/*
......@@ -7821,7 +7820,7 @@ static bool mysql_inplace_alter_table(THD *thd,
{
// Remove TABLE and TABLE_SHARE for old name from TDC.
tdc_remove_table(thd, TDC_RT_REMOVE_ALL,
alter_ctx->db.str, alter_ctx->table_name.str, false);
alter_ctx->db.str, alter_ctx->table_name.str);
if (mysql_rename_table(db_type, &alter_ctx->db, &alter_ctx->table_name,
&alter_ctx->new_db, &alter_ctx->new_alias, 0))
......
......@@ -361,7 +361,7 @@ bool Sql_cmd_truncate_table::lock_table(THD *thd, TABLE_LIST *table_ref,
{
/* Table is already locked exclusively. Remove cached instances. */
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, table_ref->db.str,
table_ref->table_name.str, FALSE);
table_ref->table_name.str);
}
DBUG_RETURN(FALSE);
......
......@@ -646,7 +646,8 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views,
*/
if (!res)
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db.str, view->table_name.str, false);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db.str,
view->table_name.str);
if (!res && mysql_bin_log.is_open())
{
......@@ -1866,8 +1867,8 @@ bool mysql_drop_view(THD *thd, TABLE_LIST *views, enum_drop_mode drop_mode)
For a view, there is a TABLE_SHARE object.
Remove it from the table definition cache, in case the view was cached.
*/
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db.str, view->table_name.str,
FALSE);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->db.str,
view->table_name.str);
query_cache_invalidate3(thd, view, 0);
sp_cache_invalidate();
}
......
......@@ -1003,47 +1003,6 @@ void tdc_release_share(TABLE_SHARE *share)
}
/**
Auxiliary function which allows to kill delayed threads for
particular table identified by its share.
@param share Table share.
@pre Caller should have TABLE_SHARE::tdc.LOCK_table_share mutex.
*/
static void kill_delayed_threads_for_table(TDC_element *element)
{
All_share_tables_list::Iterator it(element->all_tables);
TABLE *tab;
mysql_mutex_assert_owner(&element->LOCK_table_share);
if (!delayed_insert_threads)
return;
while ((tab= it++))
{
THD *in_use= tab->in_use;
DBUG_ASSERT(in_use && tab->s->tdc->flushed);
if ((in_use->system_thread & SYSTEM_THREAD_DELAYED_INSERT) &&
! in_use->killed)
{
in_use->killed= KILL_SYSTEM_THREAD;
mysql_mutex_lock(&in_use->mysys_var->mutex);
if (in_use->mysys_var->current_cond)
{
mysql_mutex_lock(in_use->mysys_var->current_mutex);
mysql_cond_broadcast(in_use->mysys_var->current_cond);
mysql_mutex_unlock(in_use->mysys_var->current_mutex);
}
mysql_mutex_unlock(&in_use->mysys_var->mutex);
}
}
}
/**
Remove all or some (depending on parameter) instances of TABLE and
TABLE_SHARE from the table definition cache.
......@@ -1077,15 +1036,13 @@ static void kill_delayed_threads_for_table(TDC_element *element)
metadata lock on the table.
@param db Name of database
@param table_name Name of table
@param kill_delayed_threads If TRUE, kill INSERT DELAYED threads
@note It assumes that table instances are already not used by any
(other) thread (this should be achieved by using meta-data locks).
*/
bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
const char *db, const char *table_name,
bool kill_delayed_threads)
const char *db, const char *table_name)
{
Share_free_tables::List purge_tables;
TABLE *table;
......@@ -1129,9 +1086,6 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
tc_remove_all_unused_tables(element, &purge_tables,
remove_type != TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE);
if (kill_delayed_threads)
kill_delayed_threads_for_table(element);
if (remove_type == TDC_RT_REMOVE_NOT_OWN ||
remove_type == TDC_RT_REMOVE_NOT_OWN_KEEP_SHARE)
{
......
......@@ -82,8 +82,7 @@ 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);
extern bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
const char *db, const char *table_name,
bool kill_delayed_threads);
const char *db, const char *table_name);
extern int tdc_wait_for_old_version(THD *thd, const char *db,
const char *table_name,
......
......@@ -67,7 +67,7 @@ static int MDL_and_TDC(THD *thd,
table);
return error;
}
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table, false);
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, db, table);
return error;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment