summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-03-07 08:12:26 +0400
committerAndrei Elkin <andrei.elkin@mariadb.com>2019-03-09 13:56:26 +0200
commitda4af18cf08809b732cc9a44c84fffd376d94dd9 (patch)
tree73d3e89f3a81290028fffb73359172266a708f3f
parent5a796f1f41a5bc0afb638cc342095e59a5bb15df (diff)
downloadmariadb-git-da4af18cf08809b732cc9a44c84fffd376d94dd9.tar.gz
Moved current_linfo under #ifdef HAVE_REPLICATION
Also set current_linfo under THD::LOCK_thd_data protection to avoid data race. Pre-requisite for clean MDEV-18450 solution.
-rw-r--r--sql/sql_class.cc2
-rw-r--r--sql/sql_class.h27
-rw-r--r--sql/sql_repl.cc20
3 files changed, 28 insertions, 21 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index bbba5218989..e2bc6ef1d90 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -644,6 +644,7 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
m_tmp_tables_locked(false)
#ifdef HAVE_REPLICATION
,
+ current_linfo(0),
slave_info(0)
#endif
#ifdef WITH_WSREP
@@ -751,7 +752,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier, bool skip_global_sys_var_lock)
progress.arena= 0;
progress.report_to_client= 0;
progress.max_counter= 0;
- current_linfo = 0;
slave_thread = 0;
connection_name.str= 0;
connection_name.length= 0;
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 23c51067734..70f0e04efe5 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -3194,12 +3194,6 @@ public:
/** number of name_const() substitutions, see sp_head.cc:subst_spvars() */
uint query_name_consts;
- /*
- If we do a purge of binary logs, log index info of the threads
- that are currently reading it needs to be adjusted. To do that
- each thread that is using LOG_INFO needs to adjust the pointer to it
- */
- LOG_INFO* current_linfo;
NET* slave_net; // network connection from slave -> m.
/*
@@ -4813,8 +4807,17 @@ private:
public:
#ifdef HAVE_REPLICATION
+ /*
+ If we do a purge of binary logs, log index info of the threads
+ that are currently reading it needs to be adjusted. To do that
+ each thread that is using LOG_INFO needs to adjust the pointer to it
+ */
+ LOG_INFO *current_linfo;
Slave_info *slave_info;
+ void set_current_linfo(LOG_INFO *linfo);
+ void reset_current_linfo() { set_current_linfo(0); }
+
int register_slave(uchar *packet, size_t packet_length);
void unregister_slave();
#endif
@@ -4975,18 +4978,6 @@ public:
(THD_TRANS::DID_WAIT | THD_TRANS::CREATED_TEMP_TABLE |
THD_TRANS::DROPPED_TEMP_TABLE | THD_TRANS::DID_DDL));
}
- /*
- Reset current_linfo
- Setting current_linfo to 0 needs to be done with LOCK_thd_data to
- ensure that adjust_linfo_offsets doesn't use a structure that may
- be deleted.
- */
- inline void reset_current_linfo()
- {
- mysql_mutex_lock(&LOCK_thd_data);
- current_linfo= 0;
- mysql_mutex_unlock(&LOCK_thd_data);
- }
uint get_net_wait_timeout()
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7fc3bb5926d..cbcfb2197df 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -506,6 +506,22 @@ static enum enum_binlog_checksum_alg get_binlog_checksum_value_at_connect(THD *
DBUG_RETURN(ret);
}
+
+/**
+ Set current_linfo
+
+ Setting current_linfo needs to be done with LOCK_thd_data to ensure that
+ adjust_linfo_offsets doesn't use a structure that may be deleted.
+*/
+
+void THD::set_current_linfo(LOG_INFO *linfo)
+{
+ mysql_mutex_lock(&LOCK_thd_data);
+ current_linfo= linfo;
+ mysql_mutex_unlock(&LOCK_thd_data);
+}
+
+
/*
Adjust the position pointer in the binary log file for all running slaves
@@ -2127,7 +2143,7 @@ static int init_binlog_sender(binlog_send_info *info,
linfo->pos= *pos;
// note: publish that we use file, before we open it
- thd->current_linfo= linfo;
+ thd->set_current_linfo(linfo);
if (check_start_offset(info, linfo->log_file_name, *pos))
return 1;
@@ -3952,7 +3968,7 @@ bool mysql_show_binlog_events(THD* thd)
goto err;
}
- thd->current_linfo= &linfo;
+ thd->set_current_linfo(&linfo);
if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0)
goto err;