summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2002-03-30 12:36:05 -0700
committerunknown <sasha@mysql.sashanet.com>2002-03-30 12:36:05 -0700
commit5449b03bc83cc6917e47c4f50a630a189a595c3d (patch)
treead398b75895850d75ea225d34b9dc052ac6d9f37 /sql/sql_repl.cc
parentef261914d3fdaaf25f1415b8625cc9ff89f9266a (diff)
downloadmariadb-git-5449b03bc83cc6917e47c4f50a630a189a595c3d.tar.gz
replication updates. This changeset seems to be working fine on test systems.
If no problems are discovered in the next week, this will make the replication code ready for 4.0.2 release. dbug/dbug.c: cleanup of my previous fix sql/mysqld.cc: fixed a REALLY NASTY BUG - slave threads were being launched before initialization of global thread keys. Thus if the slave thread was slow to start everything worked fine, but if it started quickly, we would get into trouble using the unitinialized keys sql/net_pkg.cc: make net_printf() work with 0 error code taking the third argument as format string in that case sql/slave.cc: misc fix-ups and debugging instrumentations sql/slave.h: added skip_log_purge member sql/sql_class.cc: debugging instrumentation to track down random memory corruption sql/sql_class.h: added debugging sentry to THD to track down memory corruption sql/sql_repl.cc: fixed bugs in CHANGE MASTER
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index bbe92f3e526..8216dec815a 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -714,7 +714,10 @@ int change_master(THD* thd, MASTER_INFO* mi)
return 1;
}
- pthread_mutex_lock(&mi->data_lock);
+ /* data lock not needed since we have already stopped the running threads,
+ and we have the hold on the run locks which will keep all threads that
+ could possibly modify the data structures from running
+ */
if ((lex_mi->host || lex_mi->port) && !lex_mi->log_file_name && !lex_mi->pos)
{
// if we change host or port, we must reset the postion
@@ -746,6 +749,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
if (lex_mi->relay_log_name)
{
need_relay_log_purge = 0;
+ mi->rli.skip_log_purge=1;
strnmov(mi->rli.relay_log_name,lex_mi->relay_log_name,
sizeof(mi->rli.relay_log_name));
}
@@ -759,16 +763,14 @@ int change_master(THD* thd, MASTER_INFO* mi)
flush_master_info(mi);
if (need_relay_log_purge)
{
- pthread_mutex_unlock(&mi->data_lock);
+ mi->rli.skip_log_purge=0;
thd->proc_info="purging old relay logs";
if (purge_relay_logs(&mi->rli,0 /* not only reset, but also reinit*/,
&errmsg))
{
- send_error(&thd->net, 0, "Failed purging old relay logs");
- unlock_slave_threads(mi);
+ net_printf(&thd->net, 0, "Failed purging old relay logs: %s",errmsg);
return 1;
}
- pthread_mutex_lock(&mi->rli.data_lock);
}
else
{
@@ -778,6 +780,7 @@ int change_master(THD* thd, MASTER_INFO* mi)
0 /*no data lock*/,
&msg))
{
+ //Sasha: note that I had to change net_printf() to make this work
net_printf(&thd->net,0,"Failed initializing relay log position: %s",msg);
unlock_slave_threads(mi);
return 1;
@@ -789,7 +792,10 @@ int change_master(THD* thd, MASTER_INFO* mi)
sizeof(mi->rli.master_log_name));
if (!mi->rli.master_log_name[0]) // uninitialized case
mi->rli.master_log_pos=0;
- pthread_cond_broadcast(&mi->rli.data_cond);
+
+ pthread_mutex_lock(&mi->rli.data_lock);
+ mi->rli.abort_pos_wait = 1;
+ pthread_cond_broadcast(&mi->data_cond);
pthread_mutex_unlock(&mi->rli.data_lock);
thd->proc_info = "starting slave";