diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 995a899..7d5f915 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -894,6 +894,12 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) wsrep_affected_rows = 0; wsrep_replicate_GTID = false; wsrep_skip_wsrep_GTID = false; + + /* + LOCK_wsrep_thd must be locked before LOCK_thd_kill as there should + be no other mutex taken inside LOCK_thd_kill + */ + mysql_mutex_record_order(&LOCK_wsrep_thd, &LOCK_thd_kill); #endif /* Call to init() below requires fully initialized Open_tables_state. */ reset_open_tables_state(this); @@ -1839,6 +1845,8 @@ void THD::awake(killed_state state_to_set) /* Set the 'killed' flag of 'this', which is the target THD object. */ mysql_mutex_lock(&LOCK_thd_kill); set_killed_no_mutex(state_to_set); + if (!system_thread && mysys_var) + mysys_var->abort= 1; // Abort locks in mysys if (state_to_set >= KILL_CONNECTION || state_to_set == NOT_KILLED) { @@ -1857,6 +1865,7 @@ void THD::awake(killed_state state_to_set) if (!slave_thread) MYSQL_CALLBACK(scheduler, post_kill_notification, (this)); } + mysql_mutex_unlock(&LOCK_thd_kill); /* Interrupt target waiting inside a storage engine. */ if (state_to_set != NOT_KILLED) @@ -1866,8 +1875,6 @@ void THD::awake(killed_state state_to_set) if (mysys_var) { mysql_mutex_lock(&mysys_var->mutex); - if (!system_thread) // Don't abort locks - mysys_var->abort=1; /* This broadcast could be up in the air if the victim thread @@ -1924,7 +1931,6 @@ void THD::awake(killed_state state_to_set) } mysql_mutex_unlock(&mysys_var->mutex); } - mysql_mutex_unlock(&LOCK_thd_kill); DBUG_VOID_RETURN; }