summaryrefslogtreecommitdiff
path: root/sql/semisync_master.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-03-20 18:35:20 +0400
committerSergey Vojtovich <svoj@mariadb.org>2019-05-03 16:46:11 +0400
commit779fb636daf4c127dbb90f75bab004ac1bbe12df (patch)
tree1dadbcd2ec8ce402d0875c04b8b181108d2f8481 /sql/semisync_master.cc
parent894df7edb67b888c41eae5ffbe654ceba97c6b8f (diff)
downloadmariadb-git-779fb636daf4c127dbb90f75bab004ac1bbe12df.tar.gz
Revert THD::THD(skip_global_sys_var_lock) argumentbb-10.3-svoj-MDEV-14984
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
Diffstat (limited to 'sql/semisync_master.cc')
-rw-r--r--sql/semisync_master.cc11
1 files changed, 6 insertions, 5 deletions
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;