summaryrefslogtreecommitdiff
path: root/sql/rpl_reporting.cc
diff options
context:
space:
mode:
authorunknown <mats@kindahl-laptop.dnsalias.net>2007-06-09 07:19:37 +0200
committerunknown <mats@kindahl-laptop.dnsalias.net>2007-06-09 07:19:37 +0200
commit79a609aa73c7b6fcc9b1b010e56f22fc8c1e86de (patch)
treecdc21b3b7f0f7811d04f8bafebcee2697b8a7d3b /sql/rpl_reporting.cc
parent0bcf78df8adb729d2d90961438d7cab7cd9bd019 (diff)
downloadmariadb-git-79a609aa73c7b6fcc9b1b010e56f22fc8c1e86de.tar.gz
BUG#24954 (Last_errno and Last_error not set after master_retry_count was reached):
Adding new fields Last_{IO,SQL}_Errno and Last_{IO,SQL}_Error to output of SHOW SLAVE STATUS to hold errors from I/O and SQL thread respectively. Old fields Last_Error and Last_Errno are aliases for Last_SQL_Error and Last_SQL_Errno respectively. Fields are added last to output of SHOW SLAVE STATUS to allow old applications to use the same positional arguments into the row, while allowing new application to benefit from the added information. In addition, some new error codes are added (especially for the I/O thread) to be able to provide sensible error message. mysql-test/extra/rpl_tests/rpl_max_relay_size.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/r/binlog_row_mix_innodb_myisam.result: Result change mysql-test/r/rpl_000015.result: Result change mysql-test/r/rpl_change_master.result: Result change mysql-test/r/rpl_deadlock_innodb.result: Result change mysql-test/r/rpl_empty_master_crash.result: Result change mysql-test/r/rpl_extraCol_innodb.result: Result change --- Result change. mysql-test/r/rpl_extraCol_myisam.result: Result change --- Result change. mysql-test/r/rpl_flushlog_loop.result: Result change mysql-test/r/rpl_loaddata.result: Result change mysql-test/r/rpl_log_pos.result: Result change mysql-test/r/rpl_ndb_basic.result: Result change mysql-test/r/rpl_ndb_extraCol.result: Result change --- Result change. mysql-test/r/rpl_ndb_idempotent.result: Result change mysql-test/r/rpl_ndb_log.result: Result change mysql-test/r/rpl_openssl.result: Result change mysql-test/r/rpl_rbr_to_sbr.result: Result change mysql-test/r/rpl_redirect.result: Result change mysql-test/r/rpl_replicate_do.result: Result change mysql-test/r/rpl_rotate_logs.result: Result change mysql-test/r/rpl_row_inexist_tbl.result: Result change mysql-test/r/rpl_row_log.result: Result change mysql-test/r/rpl_row_log_innodb.result: Result change mysql-test/r/rpl_row_max_relay_size.result: Result change mysql-test/r/rpl_row_reset_slave.result: Result change mysql-test/r/rpl_row_tabledefs_2myisam.result: Result change --- Result change. mysql-test/r/rpl_row_tabledefs_3innodb.result: Result change --- Result change. mysql-test/r/rpl_row_until.result: Result change mysql-test/r/rpl_server_id1.result: Result change mysql-test/r/rpl_server_id2.result: Result change mysql-test/r/rpl_slave_status.result: Result change mysql-test/r/rpl_stm_log.result: Result change mysql-test/r/rpl_stm_max_relay_size.result: Result change --- Result change. mysql-test/r/rpl_stm_reset_slave.result: Result change mysql-test/r/rpl_stm_until.result: Result change mysql-test/t/binlog_row_mix_innodb_myisam.test: Test fixed. mysql-test/t/rpl_000015.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_change_master.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_empty_master_crash.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_flushlog_loop.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_log_pos.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_bank.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_basic.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_idempotent.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_ndb_sync.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_openssl.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_rbr_to_sbr.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_redirect.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_replicate_do.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_rotate_logs.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_row_inexist_tbl.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_row_until.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_server_id1.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_server_id2.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_slave_status.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno mysql-test/t/rpl_stm_until.test: Commenting out irrelevant fields Last_IO_Error and Last_IO_Errno sql/Makefile.am: Adding new files sql/log_event.cc: Changes to use Slave_reporting_capability for reporting errors. Adding debug variable to stop slave with an out-of-memory error or with a fatal error. The checks are put both in the new Execute_load_query_ log_event and in the old Load_log_event which is used for Execute_load_ log_event. Adding code to generate fatal error message. Eliminating redundant arguments when printing ER_NO_DEFAULT_FOR_FIELD message. sql/rpl_mi.cc: Using Slave_reporting_capability for error reporting. sql/rpl_mi.h: Using Slave_reporting_capability to handle I/O thread errors and other messages. sql/rpl_rli.cc: Using Slave_reporting_capability to handle SQL thread errors and other messages. sql/rpl_rli.h: Changes to use Slave_reporting_capability for reporting SQL thread error and other messages. sql/rpl_utility.cc: Changes to use Slave_reporting_capability for reporting errors. sql/slave.cc: Changes to use Slave_reporting_capability for reporting errors. sql/slave.h: Removing slave_print_msg() sql/share/errmsg.txt: New error messages. Making message for ER_NO_DEFAULT_FOR_FIELD consistent over languages (actually restoring old message). Adding argument to ER_SLAVE_FATAL_ERROR message. sql/sql_repl.cc: Using new names for thread masks. mysql-test/t/rpl_loaddata_fatal-slave.opt: New BitKeeper file ``mysql-test/t/rpl_loaddata_fatal-slave.opt'' sql/rpl_reporting.cc: New BitKeeper file ``sql/rpl_reporting.cc'' sql/rpl_reporting.h: New BitKeeper file ``sql/rpl_reporting.h'' mysql-test/include/show_slave_status.inc: New BitKeeper file ``mysql-test/include/show_slave_status.inc'' mysql-test/r/rpl_loaddata_fatal.result: New BitKeeper file ``mysql-test/r/rpl_loaddata_fatal.result'' mysql-test/t/rpl_loaddata_fatal.test: New BitKeeper file ``mysql-test/t/rpl_loaddata_fatal.test''
Diffstat (limited to 'sql/rpl_reporting.cc')
-rw-r--r--sql/rpl_reporting.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/sql/rpl_reporting.cc b/sql/rpl_reporting.cc
new file mode 100644
index 00000000000..d14dbdcc930
--- /dev/null
+++ b/sql/rpl_reporting.cc
@@ -0,0 +1,47 @@
+
+#include "mysql_priv.h"
+#include "rpl_reporting.h"
+
+void
+Slave_reporting_capability::report(loglevel level, int err_code, const char *msg, ...)
+{
+ void (*report_function)(const char *, ...);
+ char buff[MAX_SLAVE_ERRMSG];
+ char *pbuff= buff;
+ uint pbuffsize= sizeof(buff);
+ va_list args;
+ va_start(args, msg);
+
+ switch (level)
+ {
+ case ERROR_LEVEL:
+ /*
+ It's an error, it must be reported in Last_error and Last_errno in SHOW
+ SLAVE STATUS.
+ */
+ pbuff= last_error.message;
+ pbuffsize= sizeof(last_error.message);
+ last_error.number = err_code;
+ report_function= sql_print_error;
+ break;
+ case WARNING_LEVEL:
+ report_function= sql_print_warning;
+ break;
+ case INFORMATION_LEVEL:
+ report_function= sql_print_information;
+ break;
+ default:
+ DBUG_ASSERT(0); // should not come here
+ return; // don't crash production builds, just do nothing
+ }
+
+ my_vsnprintf(pbuff, pbuffsize, msg, args);
+
+ va_end(args);
+
+ /* If the msg string ends with '.', do not add a ',' it would be ugly */
+ report_function("Slave %s: %s%s Error_code: %d",
+ m_thread_name, pbuff,
+ (pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
+ err_code);
+}