diff options
author | unknown <guilhem@mysql.com> | 2003-07-24 22:29:09 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2003-07-24 22:29:09 +0200 |
commit | 14d9a2e5e700afc0562b21fbc97412092a81656f (patch) | |
tree | 8f765bda8717ff7cf0ea26f2975079c235c32e58 /sql/sql_repl.cc | |
parent | ab34adf66acb0830a1105777b31a427da1e49b63 (diff) | |
download | mariadb-git-14d9a2e5e700afc0562b21fbc97412092a81656f.tar.gz |
Fix for BUG#858 "CHANGE MASTER forgets to update relay-log.info";
just a flush_relay_log_info() at the end of CHANGE MASTER
(there was already flush_master_info()).
sql/sql_repl.cc:
Comments.
Flush relay-log.info after CHANGE MASTER, or the changes
to the relay log parameters (relay log name and position, and
the corresponding master's binlog name and position) will be
lost if the slave mysqld is shutdown immediately after the
CHANGE MASTER (without the slave threads being started).
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 13b22d6a221..faa18b146bb 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -878,9 +878,14 @@ int change_master(THD* thd, MASTER_INFO* mi) and we have the hold on the run locks which will keep all threads that could possibly modify the data structures from running */ + + /* + If the user specified host or port without binlog or position, + reset binlog's name to FIRST and position to 4. + */ + 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 mi->master_log_name[0] = 0; mi->master_log_pos= BIN_LOG_HEADER_SIZE; mi->rli.pending = 0; @@ -950,15 +955,24 @@ int change_master(THD* thd, MASTER_INFO* mi) DBUG_RETURN(1); } } - mi->rli.master_log_pos = mi->master_log_pos; DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + mi->rli.master_log_pos = mi->master_log_pos; strmake(mi->rli.master_log_name,mi->master_log_name, sizeof(mi->rli.master_log_name)-1); if (!mi->rli.master_log_name[0]) // uninitialized case mi->rli.master_log_pos=0; pthread_mutex_lock(&mi->rli.data_lock); - mi->rli.abort_pos_wait++; + mi->rli.abort_pos_wait++; /* for MASTER_POS_WAIT() to abort */ + /* + If we don't write new coordinates to disk now, then old will remain in + relay-log.info until START SLAVE is issued; but if mysqld is shutdown + before START SLAVE, then old will remain in relay-log.info, and will be the + in-memory value at restart (thus causing errors, as the old relay log does + not exist anymore). + */ + flush_relay_log_info(&mi->rli); pthread_cond_broadcast(&mi->data_cond); pthread_mutex_unlock(&mi->rli.data_lock); |