1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Michael Widenius
2013-01-11 00:22:14 +02:00
parent 396f4d62c6
commit 6e9a48b67f
17 changed files with 185 additions and 37 deletions

View File

@ -2703,6 +2703,19 @@ public:
{
return ::killed_errno(killed);
}
inline void reset_killed()
{
/*
Resetting killed has to be done under a mutex to ensure
its not done during an awake() call.
*/
if (killed != NOT_KILLED)
{
mysql_mutex_lock(&LOCK_thd_data);
killed= NOT_KILLED;
mysql_mutex_unlock(&LOCK_thd_data);
}
}
inline void send_kill_message() const
{
int err= killed_errno();
@ -2716,6 +2729,17 @@ public:
(!transaction.stmt.modified_non_trans_table ||
(variables.sql_mode & MODE_STRICT_ALL_TABLES)));
}
/*
Increase level of kill ; Ensures that thd_killed() returns true.
Needed if storage engine wants to abort things because of a 'soft' (ie,
safe) kill but still uses thd_killed() to check if it's killed.
*/
inline void mark_as_hard_kill()
{
DBUG_ASSERT(killed != NOT_KILLED);
killed= (killed_state) (killed | KILL_HARD_BIT);
}
void set_status_var_init();
void reset_n_backup_open_tables_state(Open_tables_backup *backup);
void restore_backup_open_tables_state(Open_tables_backup *backup);