diff options
author | unknown <mats@mysql.com> | 2004-11-25 09:26:45 +0100 |
---|---|---|
committer | unknown <mats@mysql.com> | 2004-11-25 09:26:45 +0100 |
commit | 6f2cf12aa63a3b88ebf363576550ec5ae4954978 (patch) | |
tree | 2a950449e3650d6c0857e79a0a83cc2595692170 /sql | |
parent | 442b2d89b1992dd727eae1c59c16499d052ceb54 (diff) | |
download | mariadb-git-6f2cf12aa63a3b88ebf363576550ec5ae4954978.tar.gz |
Fix for Bug#6148. Only rewind read position in binary log when the
slave SQL thread is started.
sql/slave.cc:
Adding threads to init as parameter to init_master_info.
Only rewind read position when starting SQL thread.
sql/slave.h:
Adding threads to init as parameter to init_master_info.
Only rewind read position when starting SQL thread.
sql/sql_repl.cc:
Adding threads to init as parameter to init_master_info.
Only rewind read position when starting SQL thread.
sql/repl_failsafe.cc:
Adding threads to init as parameter to init_master_info.
Only rewind read position when starting SQL thread.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/repl_failsafe.cc | 3 | ||||
-rw-r--r-- | sql/slave.cc | 14 | ||||
-rw-r--r-- | sql/slave.h | 3 | ||||
-rw-r--r-- | sql/sql_repl.cc | 6 |
4 files changed, 19 insertions, 7 deletions
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 9fa6ea843f1..84640fbc968 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -892,7 +892,8 @@ int load_master_data(THD* thd) setting active_mi, because init_master_info() sets active_mi with defaults. */ - if (init_master_info(active_mi, master_info_file, relay_log_info_file, 0)) + if (init_master_info(active_mi, master_info_file, relay_log_info_file, + 0, (SLAVE_IO | SLAVE_SQL))) send_error(&thd->net, ER_MASTER_INFO); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); diff --git a/sql/slave.cc b/sql/slave.cc index 18e0ec5929f..7e544572755 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -137,7 +137,7 @@ int init_slave() } if (init_master_info(active_mi,master_info_file,relay_log_info_file, - !master_host)) + !master_host, (SLAVE_IO | SLAVE_SQL))) { sql_print_error("Failed to initialize the master info structure"); goto err; @@ -1616,7 +1616,8 @@ void clear_last_slave_error(RELAY_LOG_INFO* rli) int init_master_info(MASTER_INFO* mi, const char* master_info_fname, const char* slave_info_fname, - bool abort_if_no_master_info_file) + bool abort_if_no_master_info_file, + int thread_mask) { int fd,error; char fname[FN_REFLEN+128]; @@ -1630,8 +1631,15 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, last time. If this case pos_in_file would be set and we would get a crash when trying to read the signature for the binary relay log. + + We only rewind the read position if we are starting the SQL + thread. The handle_slave_sql thread assumes that the read + position is at the beginning of the file, and will read the + "signature" and then fast-forward to the last position read. */ - my_b_seek(mi->rli.cur_log, (my_off_t) 0); + if (thread_mask & SLAVE_SQL) { + my_b_seek(mi->rli.cur_log, (my_off_t) 0); + } DBUG_RETURN(0); } diff --git a/sql/slave.h b/sql/slave.h index eb54e258a96..a01ff93b4af 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -411,7 +411,8 @@ void init_master_info_with_options(MASTER_INFO* mi); void clear_last_slave_error(RELAY_LOG_INFO* rli); int init_master_info(MASTER_INFO* mi, const char* master_info_fname, const char* slave_info_fname, - bool abort_if_no_master_info_file); + bool abort_if_no_master_info_file, + int thread_mask); void end_master_info(MASTER_INFO* mi); int init_relay_log_info(RELAY_LOG_INFO* rli, const char* info_fname); void end_relay_log_info(RELAY_LOG_INFO* rli); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 514fed226d2..9485031c144 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -662,7 +662,8 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) thread_mask &= thd->lex.slave_thd_opt; if (thread_mask) { - if (init_master_info(mi,master_info_file,relay_log_info_file, 0)) + if (init_master_info(mi,master_info_file,relay_log_info_file, 0, + thread_mask)) slave_errno=ER_MASTER_INFO; else if (server_id_supplied && *mi->host) slave_errno = start_slave_threads(0 /*no mutex */, @@ -867,7 +868,8 @@ int change_master(THD* thd, MASTER_INFO* mi) thd->proc_info = "Changing master"; LEX_MASTER_INFO* lex_mi = &thd->lex.mi; // TODO: see if needs re-write - if (init_master_info(mi, master_info_file, relay_log_info_file, 0)) + if (init_master_info(mi, master_info_file, relay_log_info_file, 0, + thread_mask)) { send_error(&thd->net, ER_MASTER_INFO); unlock_slave_threads(mi); |