From 779fb636daf4c127dbb90f75bab004ac1bbe12df Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 20 Mar 2019 18:35:20 +0400 Subject: Revert THD::THD(skip_global_sys_var_lock) argument Originally introduced by e972125f1 to avoid harmless wait for LOCK_global_system_variables in a newly created thread, which creation was initiated by system variable update. At the same time it opens dangerous hole, when system variable update thread already released LOCK_global_system_variables and ack_receiver thread haven't yet completed new THD construction. In this case THD constructor goes completely unprotected. Since ack_receiver.stop() waits for the thread to go down, we have to temporarily release LOCK_global_system_variables so that it doesn't deadlock with ack_receiver.run(). Unfortunately it breaks atomicity of rpl_semi_sync_master_enabled updates and makes them not serialized. LOCK_rpl_semi_sync_master_enabled was introduced to workaround the above. TODO: move ack_receiver start/stop into repl_semisync_master enable_master/disable_master under LOCK_binlog protection? Part of MDEV-14984 - regression in connect performance --- sql/semisync_master.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sql/semisync_master.cc') diff --git a/sql/semisync_master.cc b/sql/semisync_master.cc index 4e37e3af58d..f9fb4d9147d 100644 --- a/sql/semisync_master.cc +++ b/sql/semisync_master.cc @@ -352,7 +352,7 @@ Repl_semi_sync_master::Repl_semi_sync_master() int Repl_semi_sync_master::init_object() { - int result; + int result= 0; m_init_done = true; @@ -362,6 +362,8 @@ int Repl_semi_sync_master::init_object() set_wait_point(rpl_semi_sync_master_wait_point); /* Mutex initialization can only be done after MY_INIT(). */ + mysql_mutex_init(key_LOCK_rpl_semi_sync_master_enabled, + &LOCK_rpl_semi_sync_master_enabled, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_binlog, &LOCK_binlog, MY_MUTEX_INIT_FAST); mysql_cond_init(key_COND_binlog_send, @@ -383,7 +385,7 @@ int Repl_semi_sync_master::init_object() } else { - result = disable_master(); + disable_master(); } return result; @@ -421,7 +423,7 @@ int Repl_semi_sync_master::enable_master() return result; } -int Repl_semi_sync_master::disable_master() +void Repl_semi_sync_master::disable_master() { /* Must have the lock when we do enable of disable. */ lock(); @@ -446,14 +448,13 @@ int Repl_semi_sync_master::disable_master() } unlock(); - - return 0; } void Repl_semi_sync_master::cleanup() { if (m_init_done) { + mysql_mutex_destroy(&LOCK_rpl_semi_sync_master_enabled); mysql_mutex_destroy(&LOCK_binlog); mysql_cond_destroy(&COND_binlog_send); m_init_done= 0; -- cgit v1.2.1