diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index d71d29bc85a11..9d9831d920985 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9098,24 +9098,6 @@ THD *find_thread_by_id(longlong id, bool query_id) return arg.thd; } -static my_bool find_thread_with_thd_data_lock_callback(THD *thd, find_thread_callback_arg *arg) -{ - if (arg->id == (arg->query_id ? thd->query_id : (longlong) thd->thread_id)) - { - mysql_mutex_lock(&thd->LOCK_thd_kill); // Lock from delete - mysql_mutex_lock(&thd->LOCK_thd_data); // XXX DELME - arg->thd= thd; - return 1; - } - return 0; -} -THD *find_thread_by_id_with_thd_data_lock(longlong id, bool query_id) -{ - find_thread_callback_arg arg(id, query_id); - server_threads.iterate(find_thread_with_thd_data_lock_callback, &arg); - return arg.thd; -} - /** kill one thread. @@ -9132,7 +9114,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ uint error= (type == KILL_TYPE_QUERY ? ER_NO_SUCH_QUERY : ER_NO_SUCH_THREAD); DBUG_ENTER("kill_one_thread"); DBUG_PRINT("enter", ("id: %lld signal: %u", id, (uint) kill_signal)); - tmp= find_thread_by_id_with_thd_data_lock(id, type == KILL_TYPE_QUERY); + tmp= find_thread_by_id(id, type == KILL_TYPE_QUERY); if (!tmp) DBUG_RETURN(error); @@ -9159,6 +9141,7 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ faster and do a harder kill than KILL_SYSTEM_THREAD; */ + mysql_mutex_lock(&tmp->LOCK_thd_data); // for various wsrep* checks below #ifdef WITH_WSREP if (((thd->security_ctx->master_access & SUPER_ACL) || thd->security_ctx->user_matches(tmp->security_ctx)) && @@ -9180,8 +9163,8 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ else #endif /* WITH_WSREP */ { - WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d", - thd->thread_id, id, tmp->wsrep_aborter, kill_signal); + WSREP_DEBUG("kill_one_thread %llu, victim: %llu wsrep_aborter %llu by signal %d", + thd->thread_id, id, tmp->wsrep_aborter, kill_signal); tmp->awake_no_mutex(kill_signal); WSREP_DEBUG("victim: %llu taken care of", id); error= 0; @@ -9190,9 +9173,9 @@ kill_one_thread(THD *thd, longlong id, killed_state kill_signal, killed_type typ else error= (type == KILL_TYPE_QUERY ? ER_KILL_QUERY_DENIED_ERROR : ER_KILL_DENIED_ERROR); + mysql_mutex_unlock(&tmp->LOCK_thd_data); } mysql_mutex_unlock(&tmp->LOCK_thd_kill); - mysql_mutex_unlock(&tmp->LOCK_thd_data); DBUG_PRINT("exit", ("%d", error)); DBUG_RETURN(error); } diff --git a/sql/sql_show.h b/sql/sql_show.h index 8e807f0c1a549..c1845d8c1b3df 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -144,7 +144,6 @@ const char* get_one_variable(THD *thd, const SHOW_VAR *variable, /* These functions were under INNODB_COMPATIBILITY_HOOKS */ int get_quote_char_for_identifier(THD *thd, const char *name, size_t length); THD *find_thread_by_id(longlong id, bool query_id= false); -THD *find_thread_by_id_with_thd_data_lock(longlong id, bool query_id= false); class select_result_explain_buffer; /* diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 8d55e6901a566..7ca9e83a368fd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -18583,8 +18583,10 @@ static void bg_wsrep_kill_trx(void *void_arg) trx_t *victim_trx; bool aborting= false; - bf_thd= find_thread_by_id_with_thd_data_lock(arg->bf_thd_id); - thd= find_thread_by_id_with_thd_data_lock(arg->thd_id); + if ((bf_thd= find_thread_by_id(arg->bf_thd_id))) + wsrep_thd_LOCK(bf_thd); + if ((thd= find_thread_by_id(arg->thd_id))) + wsrep_thd_LOCK(thd); if (!thd || !bf_thd || !(victim_trx= thd_to_trx(thd))) goto ret0;