diff options
author | unknown <dlenev@dlenev.mshome> | 2003-09-14 00:13:41 +0400 |
---|---|---|
committer | unknown <dlenev@dlenev.mshome> | 2003-09-14 00:13:41 +0400 |
commit | 2f8f0a7e4d4d86489fc208dba00f37c74e1a0293 (patch) | |
tree | 5d68689653a823809f04d554c86913c3fe9148ab /sql/sql_repl.cc | |
parent | 6417c182df2b027d766075876ce969701d3e038a (diff) | |
download | mariadb-git-2f8f0a7e4d4d86489fc208dba00f37c74e1a0293.tar.gz |
Implemented support for START SLAVE UNTIL (WL#868)
include/mysqld_error.h:
Added error codes for warnings and error messages for START SLAVE UNTIL
mysql-test/r/rpl000015.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_empty_master_crash.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_flush_log_loop.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_log.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_log_pos.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_redirect.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_replicate_do.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
mysql-test/r/rpl_rotate_logs.result:
Fixed test because 3 new columns to SHOW SLAVE STATUS output were added
sql/lex.h:
Added UNTIL symbol
sql/log.cc:
Invalidating until_log_name comparison result if group_relay_log_name is changed
sql/log_event.cc:
Invalidating until_log_name comparison result if group_master_log_name is changed
sql/repl_failsafe.cc:
Cancel until condition if LOAD MASTER DATA is executed
sql/share/czech/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/danish/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/dutch/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/english/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/estonian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/french/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/german/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/greek/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/hungarian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/italian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/japanese/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/korean/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/norwegian-ny/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/norwegian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/polish/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/portuguese/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/romanian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/russian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/serbian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/slovak/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/spanish/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/swedish/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/share/ukrainian/errmsg.txt:
Added error and warning message for START SLAVE UNTIL
sql/slave.cc:
Fixed wrong locking order in init_relay_log_pos()
Added until condition fields to SHOW SLAVE STATUS
Added checking if UNTIL condition is reached
(added proper method, added its invocation, reorganized locking
in exec_relay_log_event() and next_event())
sql/slave.h:
Members in RELAY_LOG_INFO for storing UNTIL condition. Also
methods for for invalidation of cached UNTIL condition comparison
results
sql/sql_repl.cc:
Now honoring UNTIL clause then starting slave thread. Proper
errors and warnings.
sql/sql_yacc.yy:
Added support for UNTIL clause in START SLAVE. This involved
extraction of some of master_defs to separate master_file_def
non-terminal.
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 79 |
1 files changed, 74 insertions, 5 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 121411379f8..2abfda5e4c3 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -632,7 +632,7 @@ Increase max_allowed_packet on master"; int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) { - int slave_errno; + int slave_errno= 0; if (!thd) thd = current_thd; int thread_mask; @@ -656,21 +656,88 @@ int start_slave(THD* thd , MASTER_INFO* mi, bool net_report) if (init_master_info(mi,master_info_file,relay_log_info_file, 0)) slave_errno=ER_MASTER_INFO; else if (server_id_supplied && *mi->host) - slave_errno = start_slave_threads(0 /*no mutex */, + { + /* + If we will start SQL thread we will care about UNTIL options + If not and they are specified we will ignore them and warn user + about this fact. + */ + if (thread_mask & SLAVE_SQL) + { + pthread_mutex_lock(&mi->rli.data_lock); + + if (thd->lex.mi.pos) + { + mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_MASTER_POS; + mi->rli.until_log_pos= thd->lex.mi.pos; + /* + We don't check thd->lex.mi.log_file_name for NULL here + since it is checked in sql_yacc.yy + */ + strmake(mi->rli.until_log_name, thd->lex.mi.log_file_name, + sizeof(mi->rli.until_log_name)-1); + } + else if (thd->lex.mi.relay_log_pos) + { + mi->rli.until_condition= RELAY_LOG_INFO::UNTIL_RELAY_POS; + mi->rli.until_log_pos= thd->lex.mi.relay_log_pos; + strmake(mi->rli.until_log_name, thd->lex.mi.relay_log_name, + sizeof(mi->rli.until_log_name)-1); + } + else + clear_until_condition(&mi->rli); + + if (mi->rli.until_condition != RELAY_LOG_INFO::UNTIL_NONE) + { + /* Preparing members for effective until condition checking */ + const char *p= fn_ext(mi->rli.until_log_name); + char *p_end; + if (*p) + { + //p points to '.' + mi->rli.until_log_name_extension= strtoul(++p,&p_end, 10); + /* + p_end points to the first invalid character. If it equals + to p, no digits were found, error. If it contains '\0' it + means conversion went ok. + */ + if(p_end==p || *p_end) + slave_errno=ER_BAD_SLAVE_UNTIL_COND; + } + else + slave_errno=ER_BAD_SLAVE_UNTIL_COND; + + /* mark the cached result of the UNTIL comparison as "undefined" */ + mi->rli.until_log_names_cmp_result= + RELAY_LOG_INFO::UNTIL_LOG_NAMES_CMP_UNKNOWN; + + /* Issuing warning then started without --skip-slave-start */ + if (!opt_skip_slave_start) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_MISSING_SKIP_SLAVE, + ER(ER_MISSING_SKIP_SLAVE)); + } + + pthread_mutex_unlock(&mi->rli.data_lock); + } + else if (thd->lex.mi.pos || thd->lex.mi.relay_log_pos) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_UNTIL_COND_IGNORED, + ER(ER_UNTIL_COND_IGNORED)); + + + if(!slave_errno) + slave_errno = start_slave_threads(0 /*no mutex */, 1 /* wait for start */, mi, master_info_file,relay_log_info_file, thread_mask); + } else slave_errno = ER_BAD_SLAVE; } else - { //no error if all threads are already started, only a warning - slave_errno= 0; push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_SLAVE_WAS_RUNNING, ER(ER_SLAVE_WAS_RUNNING)); - } unlock_slave_threads(mi); @@ -777,6 +844,7 @@ int reset_slave(THD *thd, MASTER_INFO* mi) // Clear master's log coordinates (only for good display of SHOW SLAVE STATUS) mi->master_log_name[0]= 0; mi->master_log_pos= BIN_LOG_HEADER_SIZE; + clear_until_condition(&mi->rli); // close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 end_master_info(mi); // and delete these two files @@ -943,6 +1011,7 @@ int change_master(THD* thd, MASTER_INFO* mi) pthread_mutex_lock(&mi->rli.data_lock); mi->rli.abort_pos_wait++; + clear_until_condition(&mi->rli); pthread_cond_broadcast(&mi->data_cond); pthread_mutex_unlock(&mi->rli.data_lock); |