summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2020-01-15 09:06:32 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2020-01-16 11:41:54 +0200
commit82c44f8298831ad167130741b6e48e7316ef8e47 (patch)
tree796ea37fb7900c8e7f7180a21893a898c4f9be80 /sql/sql_class.h
parent7d313214641241e8ce839d9de01529c2335c620f (diff)
downloadmariadb-git-bb-10.2-MDEV-18464.tar.gz
MDEV-18464 : Killing thread can cause mutex deadlock if done concurrently with Galera/replication victim killbb-10.2-MDEV-18464
Following issues here: Whenever Galera BF (brute force) transaction decides to abort conflicting transaction it will kill that thread using thd::awake() Whenever replication selects a thread as a victim it will call thd::awake() User KILL [QUERY|CONNECTION] ... for a thread it will also call thd::awake() Whenever one of these actions is executed we will hold number of InnoDB internal mutexes and thd mutexes. Sometimes these mutexes are taken in different order causing mutex deadlock. In this patch we will fix Galera BF and user kill cases so that we enqueue victim thread to a list while we hold InnoDB mutexes and we then release them. A new background thread will pick victim thread from this new list and uses thd::awake() with no InnoDB mutexes. Idea is similar to replication background kill. This fix enforces that we take LOCK_thd_data -> lock sys mutex -> trx mutex always in this order. wsrep_mysqld.cc Here we introduce a list where victim threads are stored, condition variable to be used to wake up background thread and mutex to protect list. wsrep_thd.cc Create a new background thread to handle victim thread abort. We may take wsrep_thd_LOCK mutex here but not any InnoDB mutexes. wsrep_innobase_kill_one_trx Remove all the wsrep code that was moved to wsrep_thd.cc We just enqueue required information to background kill list and cancel victim trx lock wait if there is such. Here we have InnoDB lock sys mutex and trx mutex so here we can't take wsrep_thd_LOCK mutex. wsrep_abort_transaction Cleanup only.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index b35f9a93238..95f08acf403 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -4409,6 +4409,8 @@ public:
#ifdef WITH_WSREP
const bool wsrep_applier; /* dedicated slave applier thread */
+ bool wsrep_killer; /* dedicated background
+ kill thread */
bool wsrep_applier_closing; /* applier marked to close */
bool wsrep_client_thread; /* to identify client threads*/
bool wsrep_PA_safe;