diff options
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 18 |
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"; |