summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-06-19 17:42:37 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-11-25 18:49:51 +0400
commit092834cd2cd90c73623c019eb030f25740843e81 (patch)
tree4ae53b062ece0b56097e5926b70ee8249bcd9945 /sql
parent0aa807d10051e1231bf3d4457db16ad8e66111aa (diff)
downloadmariadb-git-092834cd2cd90c73623c019eb030f25740843e81.tar.gz
Removed kill_delayed_threads_for_table()
After 7fb9d64 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
Diffstat (limited to 'sql')
-rw-r--r--sql/rpl_gtid.cc2
-rw-r--r--sql/sql_admin.cc2
-rw-r--r--sql/sql_base.cc24
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_partition_admin.cc2
-rw-r--r--sql/sql_reload.cc2
-rw-r--r--sql/sql_rename.cc2
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/sql_truncate.cc2
-rw-r--r--sql/sql_view.cc7
-rw-r--r--sql/table_cache.cc48
-rw-r--r--sql/table_cache.h3
12 files changed, 26 insertions, 79 deletions
diff --git a/sql/rpl_gtid.cc b/sql/rpl_gtid.cc
index a159434f14b..599129b98f4 100644
--- a/sql/rpl_gtid.cc
+++ b/sql/rpl_gtid.cc
@@ -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)
diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc
index 3b15c5a505e..3d1f4c3b505 100644
--- a/sql/sql_admin.cc
+++ b/sql/sql_admin.cc
@@ -1158,7 +1158,7 @@ send_result_message:
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.
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 4b0fe1eb5d1..48cc72b312b 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -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);
/*
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 62fbd4b8880..f070ff1222f 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -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>
diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc
index 54484846609..edd2116833c 100644
--- a/sql/sql_partition_admin.cc
+++ b/sql/sql_partition_admin.cc
@@ -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. */
diff --git a/sql/sql_reload.cc b/sql/sql_reload.cc
index 5562de8d8d5..8eedffdf41a 100644
--- a/sql/sql_reload.cc
+++ b/sql/sql_reload.cc
@@ -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;
}
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index ada373546be..1c6cf52963a 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -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)
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b484d9502d5..440cc0dfba7 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -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))
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc
index bfcdda6e0e9..8e078ff02af 100644
--- a/sql/sql_truncate.cc
+++ b/sql/sql_truncate.cc
@@ -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);
diff --git a/sql/sql_view.cc b/sql/sql_view.cc
index 2011abf79ba..ecf4ba2f22d 100644
--- a/sql/sql_view.cc
+++ b/sql/sql_view.cc
@@ -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();
}
diff --git a/sql/table_cache.cc b/sql/table_cache.cc
index 15afe9bfed1..4b88be421fe 100644
--- a/sql/table_cache.cc
+++ b/sql/table_cache.cc
@@ -1004,47 +1004,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)
{
diff --git a/sql/table_cache.h b/sql/table_cache.h
index 05a1803cc50..175f25a5e28 100644
--- a/sql/table_cache.h
+++ b/sql/table_cache.h
@@ -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,