summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAndrei Elkin <andrei.elkin@mariadb.com>2017-11-16 21:14:59 +0200
committerAndrei Elkin <andrei.elkin@mariadb.com>2017-11-16 21:14:59 +0200
commit24bb6be9dc672f6cb1d88bd2d4cdab1ab87502fc (patch)
tree7b85a8cde1e060b0e267830b21370996d323ddfe /sql
parent7759ad6e6ab5a29b4fb7a1b8f4d97166e288647c (diff)
downloadmariadb-git-bb-10.2-semisync.tar.gz
MDEV-13073. Fixed failing on BB sys_vars.rpl_semi_sync_master_enabled_basic. The issue forced to add up aan argument to THD::THD and THD::init to propagate skip of a mutex locking. The lock could not be released instead as this leads to clear deadlock; the test is received a piece for concurrent ack thread start/stop.bb-10.2-semisync
Diffstat (limited to 'sql')
-rw-r--r--sql/semisync_master_ack_receiver.cc3
-rw-r--r--sql/sql_class.cc13
-rw-r--r--sql/sql_class.h15
3 files changed, 21 insertions, 10 deletions
diff --git a/sql/semisync_master_ack_receiver.cc b/sql/semisync_master_ack_receiver.cc
index 7240d10b745..6cd02419e37 100644
--- a/sql/semisync_master_ack_receiver.cc
+++ b/sql/semisync_master_ack_receiver.cc
@@ -209,7 +209,8 @@ static void init_net(NET *net, unsigned char *buff, unsigned int buff_len)
void Ack_receiver::run()
{
- THD *thd= new THD(next_thread_id());
+ // skip LOCK_global_system_variables due to the 3rd arg
+ THD *thd= new THD(next_thread_id(), false, true);
NET net;
unsigned char net_buff[REPLY_MESSAGE_MAX_LENGTH];
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index afd0c375718..a97ad06c7f6 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -693,7 +693,7 @@ extern "C" void thd_kill_timeout(THD* thd)
}
-THD::THD(my_thread_id id, bool is_wsrep_applier)
+THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
:Statement(&main_lex, &main_mem_root, STMT_CONVENTIONAL_EXECUTION,
/* statement id */ 0),
rli_fake(0), rgi_fake(0), rgi_slave(NULL),
@@ -880,7 +880,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
/* Call to init() below requires fully initialized Open_tables_state. */
reset_open_tables_state(this);
- init();
+ init(skip_global_sys_var_lock);
#if defined(ENABLED_PROFILING)
profiling.set_thd(this);
#endif
@@ -1237,10 +1237,11 @@ extern "C" my_thread_id next_thread_id_noinline()
Init common variables that has to be reset on start and on change_user
*/
-void THD::init(void)
+void THD::init(bool skip_lock)
{
DBUG_ENTER("thd::init");
- mysql_mutex_lock(&LOCK_global_system_variables);
+ if (!skip_lock)
+ mysql_mutex_lock(&LOCK_global_system_variables);
plugin_thdvar_init(this);
/*
plugin_thd_var_init() sets variables= global_system_variables, which
@@ -1253,8 +1254,8 @@ void THD::init(void)
::strmake(variables.default_master_connection.str,
global_system_variables.default_master_connection.str,
variables.default_master_connection.length);
-
- mysql_mutex_unlock(&LOCK_global_system_variables);
+ if (!skip_lock)
+ mysql_mutex_unlock(&LOCK_global_system_variables);
user_time.val= start_time= start_time_sec_part= 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index c0a6f5b0e62..b708b96053f 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3098,11 +3098,20 @@ public:
/* Debug Sync facility. See debug_sync.cc. */
struct st_debug_sync_control *debug_sync_control;
#endif /* defined(ENABLED_DEBUG_SYNC) */
- THD(my_thread_id id, bool is_wsrep_applier= false);
+ /**
+ @param id thread identifier
+ @param is_wsrep_applier thread type
+ @param skip_lock instruct whether @c LOCK_global_system_variables
+ is already locked, to not acquire it then.
+ */
+ THD(my_thread_id id, bool is_wsrep_applier= false, bool skip_lock= false);
~THD();
-
- void init(void);
+ /**
+ @param skip_lock instruct whether @c LOCK_global_system_variables
+ is already locked, to not acquire it then.
+ */
+ void init(bool skip_lock= false);
/*
Initialize memory roots necessary for query processing and (!)
pre-allocate memory for it. We can't do that in THD constructor because