From 66f4900b517681da2aed3b562158ef58679961e4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 11 Jan 2021 13:16:38 +0100 Subject: Revert "MDEV-23536 : Race condition between KILL and transaction commit" This reverts the server part of the commit 775fccea0 but keeps InnoDB part (which reverted MDEV-17092 5530a93f4). So after this both MDEV-23536 and MDEV-17092 are reverted, and the original bug is resurrected. --- sql/sql_class.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index a97f64c13b3..b68e3553a2d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3194,7 +3194,7 @@ public: void update_all_stats(); void update_stats(void); void change_user(void); - void cleanup(bool have_mutex=false); + void cleanup(void); void cleanup_after_query(); void free_connection(); void reset_for_reuse(); -- cgit v1.2.1 From 6f707430e5e24aed3720e39de6cf49dc8d18d131 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 9 Jan 2021 18:48:16 +0100 Subject: cleanup: copy RAII helpers from 10.5, cleanup test --- sql/sql_class.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index b68e3553a2d..fe920270542 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -5997,6 +5997,38 @@ class Sql_mode_save sql_mode_t old_mode; // SQL mode saved at construction time. }; +class Abort_on_warning_instant_set +{ + THD *m_thd; + bool m_save_abort_on_warning; +public: + Abort_on_warning_instant_set(THD *thd, bool temporary_value) + :m_thd(thd), m_save_abort_on_warning(thd->abort_on_warning) + { + thd->abort_on_warning= temporary_value; + } + ~Abort_on_warning_instant_set() + { + m_thd->abort_on_warning= m_save_abort_on_warning; + } +}; + +class Check_level_instant_set +{ + THD *m_thd; + enum_check_fields m_check_level; +public: + Check_level_instant_set(THD *thd, enum_check_fields temporary_value) + :m_thd(thd), m_check_level(thd->count_cuted_fields) + { + thd->count_cuted_fields= temporary_value; + } + ~Check_level_instant_set() + { + m_thd->count_cuted_fields= m_check_level; + } +}; + class Switch_to_definer_security_ctx { public: -- cgit v1.2.1 From 259a1902a066d01547e5d70ba0e4837d1be62e7b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Feb 2021 15:00:38 +0100 Subject: cleanup: THD::abort_current_cond_wait() * reuse the loop in THD::abort_current_cond_wait, don't duplicate it * find_thread_by_id should return whatever it has found, it's the caller's task not to kill COM_DAEMON (if the caller's a killer) and other minor changes --- sql/sql_class.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 77bde414b31..be61a4047ec 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3322,6 +3322,7 @@ public: if (wsrep_on_local) mysql_mutex_unlock(&LOCK_thd_data); } + void abort_current_cond_wait(bool force); /** Disconnect the associated communication endpoint. */ void disconnect(); @@ -4061,8 +4062,7 @@ public: mysql_mutex_lock(&LOCK_thd_kill); int err= killed_errno(); if (err) - my_message(err, killed_err ? killed_err->msg : ER_THD(this, err), - MYF(0)); + my_message(err, killed_err ? killed_err->msg : ER_THD(this, err), MYF(0)); mysql_mutex_unlock(&LOCK_thd_kill); } /* return TRUE if we will abort query if we make a warning now */ -- cgit v1.2.1 From 9703cffa8cb57e2fe29719f4aae3282bfae82878 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 5 Feb 2021 14:59:27 +0100 Subject: don't take mutexes conditionally --- sql/sql_class.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index be61a4047ec..39d6ec1027f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3309,18 +3309,11 @@ public: void awake_no_mutex(killed_state state_to_set); void awake(killed_state state_to_set) { - bool wsrep_on_local= variables.wsrep_on; - /* - mutex locking order (LOCK_thd_data - LOCK_thd_kill)) requires - to grab LOCK_thd_data here - */ - if (wsrep_on_local) - mysql_mutex_lock(&LOCK_thd_data); + mysql_mutex_lock(&LOCK_thd_data); mysql_mutex_lock(&LOCK_thd_kill); awake_no_mutex(state_to_set); mysql_mutex_unlock(&LOCK_thd_kill); - if (wsrep_on_local) - mysql_mutex_unlock(&LOCK_thd_data); + mysql_mutex_unlock(&LOCK_thd_data); } void abort_current_cond_wait(bool force); -- cgit v1.2.1 From eac8341df4c3c7b98360f4e9498acf393dc055e3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 7 Feb 2021 17:48:58 +0100 Subject: MDEV-23328 Server hang due to Galera lock conflict resolution adaptation of 29bbcac0ee8 for 10.4 --- sql/sql_class.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_class.h') diff --git a/sql/sql_class.h b/sql/sql_class.h index 39d6ec1027f..4eabd3da450 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3309,11 +3309,11 @@ public: void awake_no_mutex(killed_state state_to_set); void awake(killed_state state_to_set) { - mysql_mutex_lock(&LOCK_thd_data); mysql_mutex_lock(&LOCK_thd_kill); + mysql_mutex_lock(&LOCK_thd_data); awake_no_mutex(state_to_set); - mysql_mutex_unlock(&LOCK_thd_kill); mysql_mutex_unlock(&LOCK_thd_data); + mysql_mutex_unlock(&LOCK_thd_kill); } void abort_current_cond_wait(bool force); -- cgit v1.2.1