diff options
author | unknown <aelkin/andrei@mysql1000.(none)> | 2008-02-20 23:18:01 +0200 |
---|---|---|
committer | unknown <aelkin/andrei@mysql1000.(none)> | 2008-02-20 23:18:01 +0200 |
commit | e19c8e2ebfdb5c2a50e71d4192681b8b4bd4efad (patch) | |
tree | 447e2f8a12f3ddd11a3e3a0b0c454e48f2a0c25a /sql/slave.cc | |
parent | e05e6814fb2b48efccc9336252dc72f550a67169 (diff) | |
download | mariadb-git-e19c8e2ebfdb5c2a50e71d4192681b8b4bd4efad.tar.gz |
Bug #31316 Report server id clashes in SHOW SLAVE STATUS
"Server_IO_State" field
Critical error messages from get_master_version_and_clock() were written
only to the slave errorlog while Show slave status did not display any
incident happened.
Although the artifact was reported for a particular --replicate-same-server-id
related issue the fix refines all critical error reporting with
deploying rli->report().
The test for the bug covers only --replicate-same-server-id error reporting.
mysql-test/suite/rpl/r/rpl_server_id1.result:
new results reflecting changes
mysql-test/suite/rpl/t/rpl_server_id1.test:
Preserving the idea of the test unnecessary queries and the sleep are
eliminated.
In the end the slave must stop with the error displayable via $$$.
sql/slave.cc:
improving get_master_version_and_clock() code to report a critical incident
via rli->report() that takes care of bothe the error log and
the slave's status info placeholders.
A critical error that force the IO slave thread to terminate is handled
immediately (goto err).
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index ea0dde942da..1880dcf0d43 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -747,7 +747,11 @@ int init_intvar_from_file(int* var, IO_CACHE* f, int default_val) static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) { + char err_buff[MAX_SLAVE_ERRMSG]; const char* errmsg= 0; + int err_code= 0; + MYSQL_RES *master_res= 0; + MYSQL_ROW master_row; DBUG_ENTER("get_master_version_and_clock"); /* @@ -758,7 +762,11 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) mi->rli.relay_log.description_event_for_queue= 0; if (!my_isdigit(&my_charset_bin,*mysql->server_version)) + { errmsg = "Master reported unrecognized MySQL version"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } else { /* @@ -770,6 +778,8 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) case '1': case '2': errmsg = "Master reported unrecognized MySQL version"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); break; case '3': mi->rli.relay_log.description_event_for_queue= new @@ -802,26 +812,21 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) */ if (errmsg) - { - sql_print_error(errmsg); - DBUG_RETURN(1); - } + goto err; /* as we are here, we tried to allocate the event */ if (!mi->rli.relay_log.description_event_for_queue) { - mi->report(ERROR_LEVEL, ER_SLAVE_CREATE_EVENT_FAILURE, - ER(ER_SLAVE_CREATE_EVENT_FAILURE), - "default Format_description_log_event"); - DBUG_RETURN(1); + errmsg= "default Format_description_log_event"; + err_code= ER_SLAVE_CREATE_EVENT_FAILURE; + sprintf(err_buff, ER(err_code), errmsg); + goto err; } /* Compare the master and slave's clock. Do not die if master's clock is unavailable (very old master not supporting UNIX_TIMESTAMP()?). */ - MYSQL_RES *master_res= 0; - MYSQL_ROW master_row; if (!mysql_real_query(mysql, STRING_WITH_LEN("SELECT UNIX_TIMESTAMP()")) && (master_res= mysql_store_result(mysql)) && @@ -858,11 +863,17 @@ static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) if ((master_row= mysql_fetch_row(master_res)) && (::server_id == strtoul(master_row[1], 0, 10)) && !mi->rli.replicate_same_server_id) + { errmsg= "The slave I/O thread stops because master and slave have equal \ MySQL server ids; these ids must be different for replication to work (or \ the --replicate-same-server-id option must be used on slave but this does \ not always make sense; please check the manual before using it)."; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + if (errmsg) + goto err; } /* @@ -893,10 +904,16 @@ not always make sense; please check the manual before using it)."; { if ((master_row= mysql_fetch_row(master_res)) && strcmp(master_row[0], global_system_variables.collation_server->name)) + { errmsg= "The slave I/O thread stops because master and slave have \ different values for the COLLATION_SERVER global variable. The values must \ be equal for replication to work"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + if (errmsg) + goto err; } /* @@ -921,16 +938,24 @@ be equal for replication to work"; if ((master_row= mysql_fetch_row(master_res)) && strcmp(master_row[0], global_system_variables.time_zone->get_name()->ptr())) + { errmsg= "The slave I/O thread stops because master and slave have \ different values for the TIME_ZONE global variable. The values must \ be equal for replication to work"; + err_code= ER_SLAVE_FATAL_ERROR; + sprintf(err_buff, ER(err_code), errmsg); + } mysql_free_result(master_res); + + if (errmsg) + goto err; } err: if (errmsg) { - sql_print_error(errmsg); + DBUG_ASSERT(err_code != 0); + mi->report(ERROR_LEVEL, err_code, err_buff); DBUG_RETURN(1); } |