From ad82034efa0bf6b69034657b4fcbdca88c987a3c Mon Sep 17 00:00:00 2001 From: nada Date: Sat, 21 Feb 2026 01:57:33 +0100 Subject: [PATCH] MDEV-38624: prevent parallel slave from skipping ER_CONNECTION_KILLED error --- .../rpl/include/check_slave_skip_errors.inc | 23 +++++++++++++++++++ mysql-test/suite/rpl/r/rpl_skip_error.result | 3 +++ .../r/rpl_temporary_error2_skip_all.result | 3 +++ .../suite/rpl/t/rpl_skip_error-slave.opt | 2 +- mysql-test/suite/rpl/t/rpl_skip_error.test | 2 ++ .../suite/rpl/t/rpl_temporary_error2.test | 5 ++++ .../rpl/t/rpl_temporary_error2_skip_all.test | 1 + sql/slave.cc | 17 +++++++++++++- 8 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/rpl/include/check_slave_skip_errors.inc diff --git a/mysql-test/suite/rpl/include/check_slave_skip_errors.inc b/mysql-test/suite/rpl/include/check_slave_skip_errors.inc new file mode 100644 index 0000000000000..57dfb49186a6d --- /dev/null +++ b/mysql-test/suite/rpl/include/check_slave_skip_errors.inc @@ -0,0 +1,23 @@ +# ==== Purpose ==== +# +# MDEV-38624: Verify that ER_CONNECTION_KILLED (1927) cannot be added to +# --slave-skip-errors, even when explicitly specified or when using "all". +# +# Called from tests that configure --slave-skip-errors with 1927 or "all". +# Checks that 1927 is absent from slave_skip_errors and that the expected +# warning appears in the slave error log. + +--connection slave +call mtr.add_suppression("Slave: ER_CONNECTION_KILLED .* is not allowed in --slave-skip-errors"); + +--let $skip_errors= query_get_value(SHOW VARIABLES LIKE 'slave_skip_errors', Value, 1) +if (`SELECT '$skip_errors' LIKE '%1927%'`) +{ + --die MDEV-38624: Error 1927 must not be added to slave_skip_errors +} + +--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err +--let $assert_select= ER_CONNECTION_KILLED .* is not allowed in --slave-skip-errors +--let $assert_count= 1 +--let $assert_text= Warning about ER_CONNECTION_KILLED should appear in error log +--source include/assert_grep.inc diff --git a/mysql-test/suite/rpl/r/rpl_skip_error.result b/mysql-test/suite/rpl/r/rpl_skip_error.result index 03fc8a7836f87..ec11c70d08d3a 100644 --- a/mysql-test/suite/rpl/r/rpl_skip_error.result +++ b/mysql-test/suite/rpl/r/rpl_skip_error.result @@ -1,6 +1,9 @@ include/master-slave.inc [connection master] connection slave; +call mtr.add_suppression("Slave: ER_CONNECTION_KILLED .* is not allowed in --slave-skip-errors"); +include/assert_grep.inc [Warning about ER_CONNECTION_KILLED should appear in error log] +connection slave; connection master; ==== Test Without sql_mode=strict_trans_tables ==== create table t1 (n int not null primary key); diff --git a/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result b/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result index 9819aafa5cfe2..7eaee78df02bb 100644 --- a/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result +++ b/mysql-test/suite/rpl/r/rpl_temporary_error2_skip_all.result @@ -1,5 +1,8 @@ include/master-slave.inc [connection master] +connection slave; +call mtr.add_suppression("Slave: ER_CONNECTION_KILLED .* is not allowed in --slave-skip-errors"); +include/assert_grep.inc [Warning about ER_CONNECTION_KILLED should appear in error log] call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); *** Provoke a deadlock on the slave, check that transaction retry succeeds. *** connection master; diff --git a/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt b/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt index 208da1fa72213..8f184c77e0c35 100644 --- a/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt +++ b/mysql-test/suite/rpl/t/rpl_skip_error-slave.opt @@ -1 +1 @@ ---slave-skip-errors=1062 +--slave-skip-errors=1062,1927 diff --git a/mysql-test/suite/rpl/t/rpl_skip_error.test b/mysql-test/suite/rpl/t/rpl_skip_error.test index ee11ce5ac9223..8c521c83050c4 100644 --- a/mysql-test/suite/rpl/t/rpl_skip_error.test +++ b/mysql-test/suite/rpl/t/rpl_skip_error.test @@ -26,9 +26,11 @@ # BUG#28839: Errors in strict mode silently stop SQL thread if --slave-skip-errors exists # bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic: # BUG#39393: slave-skip-errors does not work when using ROW based replication +# BUG#38624: ER_CONNECTION_KILLED must not be skippable via --slave-skip-errors source include/have_innodb.inc; source include/master-slave.inc; +--source include/check_slave_skip_errors.inc --connection slave let $initial_skipped_error= query_get_value(show global status like "Slave_skipped_errors", Value, 1); diff --git a/mysql-test/suite/rpl/t/rpl_temporary_error2.test b/mysql-test/suite/rpl/t/rpl_temporary_error2.test index 23a84a027605c..17e20100eb4d5 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary_error2.test +++ b/mysql-test/suite/rpl/t/rpl_temporary_error2.test @@ -1,6 +1,11 @@ --source include/have_innodb.inc --source include/master-slave.inc +if ($check_mdev_38624) +{ + --source include/check_slave_skip_errors.inc +} + call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); --disable_query_log call mtr.add_suppression("InnoDB: Transaction was aborted due to "); diff --git a/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test index 6801bf184d52c..bb4e79dff641b 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test +++ b/mysql-test/suite/rpl/t/rpl_temporary_error2_skip_all.test @@ -1,3 +1,4 @@ --source include/have_binlog_format_row.inc --let $ignored_db_deadlock= 1 +--let $check_mdev_38624= 1 --source rpl_temporary_error2.test diff --git a/sql/slave.cc b/sql/slave.cc index de1476e592542..03fc082590c7f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -795,6 +795,10 @@ bool init_slave_skip_errors(const char* arg) if (!system_charset_info->strnncoll((uchar*)arg,4,(const uchar*)"all",4)) { bitmap_set_all(&slave_error_mask); + bitmap_clear_bit(&slave_error_mask,ER_CONNECTION_KILLED); + sql_print_warning("Slave: ER_CONNECTION_KILLED (%d) is not allowed in " + "--slave-skip-errors=all. This error will never be skipped " + "by the slave.", ER_CONNECTION_KILLED); goto end; } for (p= arg ; *p; ) @@ -803,7 +807,18 @@ bool init_slave_skip_errors(const char* arg) if (!(p= str2int(p, 10, 0, LONG_MAX, &err_code))) break; if (err_code < MAX_SLAVE_ERROR) - bitmap_set_bit(&slave_error_mask,(uint)err_code); + { + if (err_code == ER_CONNECTION_KILLED) + { + sql_print_warning("Slave: ER_CONNECTION_KILLED (%d) is not allowed in " + "--slave-skip-errors. This error will never be skipped " + "by the slave.", ER_CONNECTION_KILLED); + } + else + { + bitmap_set_bit(&slave_error_mask,(uint)err_code); + } + } while (!my_isdigit(system_charset_info,*p) && *p) p++; }