From d61c223bb91fa127a2682565967738369c8fde62 Mon Sep 17 00:00:00 2001 From: "shuai.lou" Date: Wed, 22 Jun 2022 22:45:33 +0800 Subject: [PATCH] Bug#107635 MGR: Assertion failure in event_scheduler_thread in debug mode --- .../group_replication/r/gr_and_events.result | 15 +++++++++++++++ .../suite/group_replication/t/gr_and_events.test | 6 ++++++ sql/mysqld_thd_manager.cc | 2 +- sql/mysqld_thd_manager.h | 4 +++- sql/rpl_transaction_ctx.cc | 3 ++- 5 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 mysql-test/suite/group_replication/r/gr_and_events.result create mode 100644 mysql-test/suite/group_replication/t/gr_and_events.test diff --git a/mysql-test/suite/group_replication/r/gr_and_events.result b/mysql-test/suite/group_replication/r/gr_and_events.result new file mode 100644 index 00000000000..f49aaae045c --- /dev/null +++ b/mysql-test/suite/group_replication/r/gr_and_events.result @@ -0,0 +1,15 @@ +include/group_replication.inc +Warnings: +Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. +Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information. +[connection server1] +# +# Bug#21041908 - events+rpl: void close_thread_tables(thd*): +# assertion `thd->get_transaction() +# +SET GLOBAL EVENT_SCHEDULER = OFF; +CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND +ENDS NOW() + INTERVAL 1 SECOND DO SELECT 1; +SET GLOBAL EVENT_SCHEDULER = ON; +DROP EVENT IF EXISTS e1; +include/group_replication_end.inc diff --git a/mysql-test/suite/group_replication/t/gr_and_events.test b/mysql-test/suite/group_replication/t/gr_and_events.test new file mode 100644 index 00000000000..8fc4d192d54 --- /dev/null +++ b/mysql-test/suite/group_replication/t/gr_and_events.test @@ -0,0 +1,6 @@ +--source include/have_group_replication_plugin.inc +--source include/group_replication.inc + +--source t/events_and_binlog.test + +--source include/group_replication_end.inc diff --git a/sql/mysqld_thd_manager.cc b/sql/mysqld_thd_manager.cc index c01635e55e2..0f18d3b7d6e 100644 --- a/sql/mysqld_thd_manager.cc +++ b/sql/mysqld_thd_manager.cc @@ -57,7 +57,7 @@ static inline int thd_partition(my_thread_id thread_id) { } bool Find_thd_with_id::operator()(THD *thd) { - if (thd->get_command() == COM_DAEMON) return false; + if (thd->get_command() == COM_DAEMON && !m_daemon_allowed) return false; return (thd->thread_id() == m_thread_id); } diff --git a/sql/mysqld_thd_manager.h b/sql/mysqld_thd_manager.h index 0f8753ad5ea..99c8a51cebb 100644 --- a/sql/mysqld_thd_manager.h +++ b/sql/mysqld_thd_manager.h @@ -81,10 +81,12 @@ class Find_THD_Impl { */ class Find_thd_with_id : public Find_THD_Impl { public: - Find_thd_with_id(my_thread_id value) : m_thread_id(value) {} + Find_thd_with_id(my_thread_id value, bool daemon_allowed = false) + : m_thread_id(value), m_daemon_allowed(daemon_allowed) {} bool operator()(THD *thd) override; const my_thread_id m_thread_id; + const bool m_daemon_allowed; }; /** diff --git a/sql/rpl_transaction_ctx.cc b/sql/rpl_transaction_ctx.cc index f92e41e0605..33852569074 100644 --- a/sql/rpl_transaction_ctx.cc +++ b/sql/rpl_transaction_ctx.cc @@ -99,7 +99,8 @@ int set_transaction_ctx( transaction_termination_ctx.m_gno)); uint error = ER_NO_SUCH_THREAD; - Find_thd_with_id find_thd_with_id(transaction_termination_ctx.m_thread_id); + Find_thd_with_id find_thd_with_id(transaction_termination_ctx.m_thread_id, + true); THD_ptr thd_ptr = Global_THD_manager::get_instance()->find_thd(&find_thd_with_id); -- 2.20.1