From 6e9a48b67fceab17089ca4cd1406e302386a601b Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Fri, 11 Jan 2013 00:22:14 +0200 Subject: Fixed some race conditons and bugs related to killed queries KILL now breaks locks inside InnoDB Fixed possible deadlock when running INNODB STATUS Added ha_kill_query() and kill_query() to send kill signal to all storage engines Added reset_killed() to ensure we don't reset killed state while awake() is getting called include/mysql/plugin.h: Added thd_mark_as_hard_kill() include/mysql/plugin_audit.h.pp: Added thd_mark_as_hard_kill() include/mysql/plugin_auth.h.pp: Added thd_mark_as_hard_kill() include/mysql/plugin_ftparser.h.pp: Added thd_mark_as_hard_kill() sql/handler.cc: Added ha_kill_query() to send kill signal to all storage engines sql/handler.h: Added ha_kill_query() and kill_query() to send kill signal to all storage engines sql/log_event.cc: Use reset_killed() sql/mdl.cc: use thd->killed instead of thd_killed() to abort on soft kill sql/sp_rcontext.cc: Use reset_killed() sql/sql_class.cc: Fixed possible deadlock in INNODB STATUS by not getting thd->LOCK_thd_data if it's locked. Use reset_killed() Tell storge engines that KILL has been sent sql/sql_class.h: Added reset_killed() to ensure we don't reset killed state while awake() is getting called. Added mark_as_hard_kill() sql/sql_insert.cc: Use reset_killed() sql/sql_parse.cc: Simplify detection of killed queries. Use reset_killed() sql/sql_select.cc: Use reset_killed() sql/sql_union.cc: Use reset_killed() storage/innobase/handler/ha_innodb.cc: Added innobase_kill_query() Fixed error reporting for interrupted queries. storage/xtradb/handler/ha_innodb.cc: Added innobase_kill_query() Fixed error reporting for interrupted queries. --- include/mysql/plugin_ftparser.h.pp | 1 + 1 file changed, 1 insertion(+) (limited to 'include/mysql/plugin_ftparser.h.pp') diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 6011e7f7519..84299c77d9b 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -180,6 +180,7 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); int thd_killed(const void* thd); +void thd_mark_as_hard_kill(void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, -- cgit v1.2.1 From 750b9147fced7202b541be946e044eb739b20a03 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 15 Jan 2013 17:46:46 +0100 Subject: remove thd_mark_as_hard_kill() (because it's conceptually wrong. only the user can decide whether the kill is allowed to leave tables in the inconsistent state, storage engine has no say in that) --- include/mysql/plugin_ftparser.h.pp | 1 - 1 file changed, 1 deletion(-) (limited to 'include/mysql/plugin_ftparser.h.pp') diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 84299c77d9b..6011e7f7519 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -180,7 +180,6 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); int thd_killed(const void* thd); -void thd_mark_as_hard_kill(void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, -- cgit v1.2.1 From d41d43f42165cafe87d361f473e226fee24e91ba Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 18 Jan 2013 19:04:23 +0100 Subject: MDEV-4065 thd_kill_statement service --- include/mysql/plugin_ftparser.h.pp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include/mysql/plugin_ftparser.h.pp') diff --git a/include/mysql/plugin_ftparser.h.pp b/include/mysql/plugin_ftparser.h.pp index 6011e7f7519..fb09a97618b 100644 --- a/include/mysql/plugin_ftparser.h.pp +++ b/include/mysql/plugin_ftparser.h.pp @@ -82,6 +82,16 @@ const char *set_thd_proc_info(void*, const char * info, const char *func, const char *file, unsigned int line); #include extern void (*debug_sync_C_callback_ptr)(void*, const char *, size_t); +#include +enum thd_kill_levels { + THD_IS_NOT_KILLED=0, + THD_ABORT_SOFTLY=50, + THD_ABORT_ASAP=100, +}; +extern struct kill_statement_service_st { + enum thd_kill_levels (*thd_kill_level_func)(const void*); +} *thd_kill_statement_service; +enum thd_kill_levels thd_kill_level(const void*); struct st_mysql_xid { long formatID; long gtrid_length; @@ -179,7 +189,6 @@ char *thd_security_context(void* thd, char *buffer, unsigned int length, unsigned int max_query_len); void thd_inc_row_count(void* thd); int mysql_tmpfile(const char *prefix); -int thd_killed(const void* thd); unsigned long thd_get_thread_id(const void* thd); void thd_get_xid(const void* thd, MYSQL_XID *xid); void mysql_query_cache_invalidate4(void* thd, -- cgit v1.2.1