#At file:///home/acorreia/workspace.sun/repository.mysql/bzrwork/bug-38197/mysql-5.1-bugteam/ based on revid:matthias.leich@stripped
2768 Alfranio Correia 2009-02-05
BUG#38197 Errors in @@init_slave not visible in 'show slave status'
Some errors that cause the slave SQL thread to stop are not shown in the Slave_SQL_Error
column of "SHOW SLAVE STATUS". Instead, the error is only in the server's error log.
That makes it difficult to analyze the error for the user. One example of an error that stops the slave
but is not shown by "SHOW SLAVE STATUS" is when @@global.init_slave is set incorrectly
(e.g., it contains something that is not valid SQL).
Three failures were not correctly reported:
1 - Failures during slave thread initialization
2 - Failures while initializing the relay log position right after
starting the slave thread.
3 - Failures while processing queries passed through the init_slave
option.
This patch fixes the issues by reporting the errors through relay-info->report.
added:
mysql-test/suite/bugs/r/rpl_bug38197.result
mysql-test/suite/bugs/t/rpl_bug38197.test
modified:
mysql-test/suite/rpl/r/rpl_bug33931.result
mysql-test/suite/rpl/t/rpl_bug33931.test
sql/slave.cc
per-file messages:
mysql-test/suite/rpl/r/rpl_bug33931.result
Due to the changes on the output of SHOW SLAVE STATUS, this test result was affected.
mysql-test/suite/rpl/t/rpl_bug33931.test
Due to the changes on the output of SHOW SLAVE STATUS, this test was affected.
sql/slave.cc
Adds to relay-info->report whenever appropriate.
=== added file 'mysql-test/suite/bugs/r/rpl_bug38197.result'
--- a/mysql-test/suite/bugs/r/rpl_bug38197.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/r/rpl_bug38197.result 2009-02-05 13:22:18 +0000
@@ -0,0 +1,18 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+stop slave;
+reset slave;
+SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
+start slave;
+Reporting the following error: 1105 Failed during slave thread initialization
+SET GLOBAL debug= "";
+stop slave;
+reset slave;
+SET GLOBAL init_slave= "garbage";
+start slave;
+Reporting the following error: 1064 Slave SQL thread aborted. Can't execute init_slave query
+SET GLOBAL init_slave= "";
=== added file 'mysql-test/suite/bugs/t/rpl_bug38197.test'
--- a/mysql-test/suite/bugs/t/rpl_bug38197.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/bugs/t/rpl_bug38197.test 2009-02-05 13:22:18 +0000
@@ -0,0 +1,65 @@
+# Some errors that cause the slave SQL thread to stop are not shown in
+# the Slave_SQL_Error # column of "SHOW SLAVE STATUS". Instead, the error
+# is only in the server's error log.
+#
+# The first test injects a fault in the SQL/IO Threads thus generating
+# information to "SHOW SLAVE STATUS".
+#
+# The second tests sets @@global.init_slave to an invalid command
+# thus preventing the initialization of the SQL Thread and generating
+# information to "SHOW SLAVE STATUS".
+######################################################################
+source include/have_debug.inc;
+source include/master-slave.inc;
+source include/have_log_bin.inc;
+
+connection slave;
+
+--disable_warnings
+stop slave;
+--enable_warnings
+reset slave;
+######################################################################
+
+######################################################################
+connection slave;
+
+# Set debug flags on slave to force errors to occur
+SET GLOBAL debug= "d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
+
+start slave;
+
+#
+# slave is going to stop because of emulated failures
+# but there won't be any crashes nor asserts hit.
+#
+source include/wait_for_slave_to_stop.inc;
+
+let $errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1);
+let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
+echo Reporting the following error: $errno $error;
+
+SET GLOBAL debug= "";
+######################################################################
+
+######################################################################
+connection slave;
+
+--disable_warnings
+stop slave;
+--enable_warnings
+source include/wait_for_slave_to_stop.inc;
+
+reset slave;
+
+SET GLOBAL init_slave= "garbage";
+
+start slave;
+source include/wait_for_slave_sql_to_stop.inc;
+
+let $errno= query_get_value(SHOW SLAVE STATUS, Last_Errno, 1);
+let $error= query_get_value(SHOW SLAVE STATUS, Last_Error, 1);
+echo Reporting the following error: $errno $error;
+
+SET GLOBAL init_slave= "";
+######################################################################
=== modified file 'mysql-test/suite/rpl/r/rpl_bug33931.result'
--- a/mysql-test/suite/rpl/r/rpl_bug33931.result 2008-10-13 18:33:08 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug33931.result 2009-02-05 13:22:18 +0000
@@ -1,5 +1,5 @@
reset master;
-call mtr.add_suppression("Failed during slave.*thread initialization");
+call mtr.add_suppression("Failed during slave thread initialization");
stop slave;
reset slave;
SET GLOBAL debug="d,simulate_io_slave_error_on_init,simulate_sql_slave_error_on_init";
@@ -23,8 +23,8 @@ Replicate_Do_Table
Replicate_Ignore_Table
Replicate_Wild_Do_Table
Replicate_Wild_Ignore_Table
-Last_Errno 0
-Last_Error
+Last_Errno 1105
+Last_Error Failed during slave thread initialization
Skip_Counter 0
Exec_Master_Log_Pos 0
Relay_Log_Space #
@@ -41,6 +41,6 @@ Seconds_Behind_Master #
Master_SSL_Verify_Server_Cert No
Last_IO_Errno 0
Last_IO_Error
-Last_SQL_Errno 0
-Last_SQL_Error
+Last_SQL_Errno 1105
+Last_SQL_Error Failed during slave thread initialization
SET GLOBAL debug="";
=== modified file 'mysql-test/suite/rpl/t/rpl_bug33931.test'
--- a/mysql-test/suite/rpl/t/rpl_bug33931.test 2008-10-13 18:33:08 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug33931.test 2009-02-05 13:22:18 +0000
@@ -15,7 +15,7 @@ reset master;
connection slave;
# Add suppression for expected warnings in slaves error log
-call mtr.add_suppression("Failed during slave.*thread initialization");
+call mtr.add_suppression("Failed during slave thread initialization");
--disable_warnings
stop slave;
=== modified file 'sql/slave.cc'
--- a/sql/slave.cc 2009-01-09 12:49:24 +0000
+++ b/sql/slave.cc 2009-02-05 13:22:18 +0000
@@ -2678,7 +2678,8 @@ pthread_handler_t handle_slave_sql(void
*/
pthread_cond_broadcast(&rli->start_cond);
pthread_mutex_unlock(&rli->run_lock);
- sql_print_error("Failed during slave thread initialization");
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_ERROR,
+ "Failed during slave thread initialization");
goto err;
}
thd->init_for_queries();
@@ -2722,9 +2723,13 @@ pthread_handler_t handle_slave_sql(void
rli->group_relay_log_pos,
1 /*need data lock*/, &errmsg,
1 /*look for a description_event*/))
- {
- sql_print_error("Error initializing relay log position: %s",
- errmsg);
+ {
+ /*
+ * This error is not reported in the init_relay_log_pos.
+ * Thus, we need to report it here.
+ */
+ rli->report(ERROR_LEVEL, ER_UNKNOWN_ERROR,
+ "Error initializing relay log position: %s", errmsg);
goto err;
}
THD_CHECK_SENTRY(thd);
@@ -2769,8 +2774,8 @@ log '%s' at position %s, relay log '%s'
execute_init_command(thd, &sys_init_slave, &LOCK_sys_init_slave);
if (thd->is_slave_error)
{
- sql_print_error("\
-Slave SQL thread aborted. Can't execute init_slave query");
+ rli->report(ERROR_LEVEL, thd->main_da.sql_errno(),
+ "Slave SQL thread aborted. Can't execute init_slave query");
goto err;
}
}
@@ -2820,10 +2825,20 @@ Slave SQL thread aborted. Can't execute
thd->main_da.sql_errno(), last_errno));
if (last_errno == 0)
{
+ /*
+ * The thread is reporting an error which was not reported
+ * before. Thus, we must report it here.
+ */
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg);
}
else if (last_errno != thd->main_da.sql_errno())
{
+ /*
+ * This means that the error was reported in another place
+ * but the error code differs from what is in the thread.
+ * Thus, we print out more information to help finding
+ * what cause the problem.
+ */
sql_print_error("Slave (additional info): %s Error_code: %d",
errmsg, thd->main_da.sql_errno());
}
@@ -2843,6 +2858,12 @@ Slave SQL thread aborted. Can't execute
udf_error = true;
sql_print_warning("Slave: %s Error_code: %d",err->msg, err->code);
}
+ /*
+ * Both errors are reported in another place, so you are only
+ * printing here additional debug information.
+ * Please, check the test case rpl_incident.test to see an
+ * example.
+ */
if (udf_error)
sql_print_error("Error loading user-defined library, slave SQL "
"thread aborted. Install the missing library, and restart the "
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)Bug#38197 | Alfranio Correia | 5 Feb |