Skip to content

Commit

Permalink
MDEV-21851: Error in BINLOG_BASE64_EVENT i s always error-logged as i…
Browse files Browse the repository at this point in the history
…f it is done by Slave

The prefix of error log message out of a failed BINLOG applying
is corrected to be the sql command name.
  • Loading branch information
andrelkin committed Jun 12, 2020
1 parent 762bf7a commit e156a8d
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mysql-test/suite/binlog/include/binlog.test
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ SHOW SESSION VARIABLES LIKE "unique_checks";
--echo # INSERT INTO t1 VALUES(2)
--echo # foreign_key_checks=1 and unique_checks=1
--echo # It should not change current session's variables, even error happens
call mtr.add_suppression("Slave SQL.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
call mtr.add_suppression("BINLOG_BASE64_EVENT.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
--error 1062
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/binlog/r/binlog_base64_flag.result
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");
DROP TABLE IF EXISTS t1;
==== Test BUG#32407 ====
select * from t1;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/binlog/r/binlog_row_binlog.result
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
call mtr.add_suppression("Slave SQL.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
call mtr.add_suppression("BINLOG_BASE64_EVENT.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/binlog/r/binlog_stm_binlog.result
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ unique_checks OFF
# INSERT INTO t1 VALUES(2)
# foreign_key_checks=1 and unique_checks=1
# It should not change current session's variables, even error happens
call mtr.add_suppression("Slave SQL.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
call mtr.add_suppression("BINLOG_BASE64_EVENT.*Could not execute Write_rows_v1 event on table test.t1; Duplicate entry .2. for key .PRIMARY., Error_code: 1062");
BINLOG '
dfLtTBMBAAAAKQAAAKsBAAAAABcAAAAAAAEABHRlc3QAAnQxAAEDAAE=
dfLtTBcBAAAAIgAAAM0BAAAAABcAAAAAAAEAAf/+AgAAAA==
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/suite/binlog/t/binlog_base64_flag.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
# BINLOG statement does not work in embedded mode.
source include/not_embedded.inc;

call mtr.add_suppression("BINLOG_BASE64_EVENT: According to the master's version");
call mtr.add_suppression("BINLOG_BASE64_EVENT: Column 1 of table 'test.char128_utf8' cannot be converted");

disable_warnings;
DROP TABLE IF EXISTS t1;
enable_warnings;

# Test to show BUG#32407. This reads a binlog created with the
# mysql-5.1-telco-6.1 tree, specifically at the tag
# mysql-5.1.15-ndb-6.1.23, and applies it to the database. The test
Expand Down
4 changes: 3 additions & 1 deletion sql/rpl_reporting.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "rpl_reporting.h"
#include "log.h" // sql_print_error, sql_print_warning,
// sql_print_information
#include "sql_class.h"

Slave_reporting_capability::Slave_reporting_capability(char const *thread_name)
: m_thread_name(thread_name)
Expand Down Expand Up @@ -70,7 +71,8 @@ Slave_reporting_capability::report(loglevel level, int err_code,
va_end(args);

/* If the msg string ends with '.', do not add a ',' it would be ugly */
report_function("Slave %s: %s%s %s%sInternal MariaDB error code: %d",
report_function("%s %s: %s%s %s%sInternal MariaDB error code: %d",
(current_thd && current_thd->rgi_fake) ? "" : "Slave",
m_thread_name, pbuff,
(pbuff[0] && *(strend(pbuff)-1) == '.') ? "" : ",",
(extra_info ? extra_info : ""), (extra_info ? ", " : ""),
Expand Down
4 changes: 2 additions & 2 deletions sql/rpl_rli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ gtid_waiting rpl_global_gtid_waiting;

const char *const Relay_log_info::state_delaying_string = "Waiting until MASTER_DELAY seconds after master executed event";

Relay_log_info::Relay_log_info(bool is_slave_recovery)
:Slave_reporting_capability("SQL"),
Relay_log_info::Relay_log_info(bool is_slave_recovery, const char* thread_name)
:Slave_reporting_capability(thread_name),
replicate_same_server_id(::replicate_same_server_id),
info_fd(-1), cur_log_fd(-1), relay_log(&sync_relaylog_period),
sync_counter(0), is_relay_log_recovery(is_slave_recovery),
Expand Down
4 changes: 2 additions & 2 deletions sql/rpl_rli.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ class Relay_log_info : public Slave_reporting_capability
*/
slave_connection_state restart_gtid_pos;

Relay_log_info(bool is_slave_recovery);
Relay_log_info(bool is_slave_recovery, const char* thread_name= "SQL");
~Relay_log_info();

/*
Invalidate cached until_log_name and group_relay_log_name comparison
Invalidate cached until_log_name and group_relay_log_name comparison
result. Should be called after any update of group_realy_log_name if
there chances that sql_thread is running.
*/
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void mysql_client_binlog_statement(THD* thd)
size_t coded_len= 0, decoded_len= 0;

rli= thd->rli_fake;
if (!rli && (rli= thd->rli_fake= new Relay_log_info(FALSE)))
if (!rli && (rli= thd->rli_fake= new Relay_log_info(FALSE, "BINLOG_BASE64_EVENT")))
rli->sql_driver_thd= thd;
if (!(rgi= thd->rgi_fake))
rgi= thd->rgi_fake= new rpl_group_info(rli);
Expand Down

0 comments on commit e156a8d

Please sign in to comment.