Skip to content

Commit

Permalink
MDEV-32168: slave_error_param condition is never checked from the wai…
Browse files Browse the repository at this point in the history
…t_for_slave_param.inc

Fix some random test failures following MDEV-32168 push.

Don't blindly set $rpl_only_running_threads in many places. Instead explicit
stop only the IO or SQL thread, as appropriate. Setting it interfered with
rpl_end.inc in some cases. Rather than clearing it afterwards, better to
not set it at all when it is not needed, removing ambiguity in the test
about the state of the replication threads.

Don't fail the test if include/stop_slave_io.inc finds an error in the IO
thread after stop. Such errors can be simply because slave stop happened in
the middle of the IO thread's initial communication with the master.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
  • Loading branch information
knielsen committed Nov 28, 2023
1 parent 1ffa8c5 commit ea4bcb9
Show file tree
Hide file tree
Showing 37 changed files with 66 additions and 72 deletions.
16 changes: 11 additions & 5 deletions mysql-test/include/wait_for_slave_io_to_stop.inc
Expand Up @@ -28,6 +28,9 @@
# there is an error in the IO thread.
# (If an error is _always_ expected, a better alternative might be to
# use wait_for_slave_io_error.inc instead of this file).
# Note: This is currently always enabled, since a simple STOP SLAVE
# IO_THREAD can cause an error if it interrupts the slave's initial
# communication with the master (MDEV-32892).
#
# $rpl_debug
# See include/rpl_init.inc
Expand All @@ -39,12 +42,15 @@

--let $slave_param= Slave_IO_Running
--let $slave_param_value= No
if (!$rpl_allow_error)
{
--let $slave_error_param= Last_IO_Errno
}
--let $_io_stop_save_allow_error= $slave_error_param
# Disabled, as IO errors are left behind when a normal STOP SLAVE interrupts
# the initial communication between the IO thread and the master (MDEV-32892).
#if (!$rpl_allow_error)
#{
# --let $slave_error_param= Last_IO_Errno
#}
--source include/wait_for_slave_param.inc
--let $slave_error_param=
--let $slave_error_param= $_io_stop_save_allow_error


--let $include_filename= wait_for_slave_io_to_stop.inc
Expand Down
Expand Up @@ -63,7 +63,7 @@ include/wait_for_slave_io_error.inc [errno=1236]
SHOW TABLES;
Tables_in_test
table1_no_encryption
include/stop_slave.inc
include/stop_slave_sql.inc
reset slave;
##########
# Cleanup
Expand Down
Expand Up @@ -137,8 +137,7 @@ SHOW TABLES;

--disable_connect_log
# IO thread is stopped, stop SQL thread only
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/stop_slave_sql.inc
--enable_connect_log
reset slave;

Expand Down
Expand Up @@ -62,7 +62,7 @@ include/wait_for_slave_io_error.inc [errno=1236]
# ..success
SHOW TABLES;
Tables_in_test
include/stop_slave.inc
include/stop_slave_sql.inc
reset slave;
##########
# Cleanup
Expand Down
Expand Up @@ -133,8 +133,7 @@ SHOW TABLES;

--disable_connect_log
# IO thread is stopped, wait for SQL thread to be stopped
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/stop_slave_sql.inc
--enable_connect_log
reset slave;

Expand Down
Expand Up @@ -192,7 +192,7 @@ SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/stop_slave_io.inc
include/start_slave.inc
connection master;
connection slave;
Expand Down
Expand Up @@ -36,7 +36,7 @@ connection con_temp2;
COMMIT;
connection server_2;
include/wait_for_slave_sql_error.inc [errno=1062]
include/stop_slave.inc
include/stop_slave_io.inc
include/assert.inc [table t1 should have zero rows where a>32]
SELECT * FROM t1 WHERE a>32;
a
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/multi_source/gtid_slave_pos.result
Expand Up @@ -99,7 +99,7 @@ include/wait_for_slave_to_stop.inc
set default_master_connection = 'slave2';
include/wait_for_slave_sql_error.inc [errno=1942]
STOP SLAVE;
include/stop_slave.inc
include/wait_for_slave_io_to_stop.inc
set default_master_connection = 'slave1';
START SLAVE;
include/wait_for_slave_to_start.inc
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/multi_source/gtid_slave_pos.test
Expand Up @@ -121,8 +121,7 @@ set default_master_connection = 'slave2';
--let $slave_sql_errno= 1942
--source include/wait_for_slave_sql_error.inc
STOP SLAVE;
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/wait_for_slave_io_to_stop.inc
set default_master_connection = 'slave1';
START SLAVE;
--source include/wait_for_slave_to_start.inc
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/rpl/include/mdev-31448_conservative.inc
Expand Up @@ -36,7 +36,8 @@ insert into t1 values (3);
--connection slave
--source include/start_slave.inc

--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(-1)' and command LIKE 'Slave_worker';
# Wildcard for `state` as it depends on whether WSREP is compiled in or not.
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(%)' and command LIKE 'Slave_worker';
--source include/wait_condition.inc
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Waiting for prior transaction to commit%' and command LIKE 'Slave_worker';
--source include/wait_condition.inc
Expand Down
3 changes: 2 additions & 1 deletion mysql-test/suite/rpl/include/mdev-31448_optimistic.inc
Expand Up @@ -55,7 +55,8 @@ drop table t2;
--source include/start_slave.inc

--echo # wait for T1
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(-1)' and command LIKE 'Slave_worker';
# Wildcard for `state` as it depends on whether WSREP is compiled in or not.
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(%)' and command LIKE 'Slave_worker';
--source include/wait_condition.inc

--echo # wait for T2
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/rpl/include/rpl_binlog_max_cache_size.test
Expand Up @@ -433,8 +433,7 @@ source include/show_binlog_events.inc;
--eval SET GLOBAL binlog_stmt_cache_size= $old_binlog_stmt_cache_size

# SQL slave is stopped, stop only IO thread
--let $rpl_only_running_threads= 1
source include/stop_slave.inc;
source include/stop_slave_io.inc;
source include/start_slave.inc;

connection master;
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/rpl/include/rpl_start_stop_slave.test
Expand Up @@ -207,8 +207,7 @@ START SLAVE;
--let $status_items= Last_IO_Errno, Last_IO_Error
--source include/show_slave_status.inc

--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/stop_slave_sql.inc
RESET SLAVE;

--connection master
Expand Down
Expand Up @@ -42,7 +42,8 @@ include/save_master_gtid.inc
connection slave;
#
# Cleanup
include/stop_slave.inc
include/wait_for_slave_sql_to_stop.inc
include/stop_slave_io.inc
set @@global.slave_parallel_threads= 0;
set @@global.slave_parallel_mode= conservative;
set @@global.innodb_lock_wait_timeout= 50;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_connection.result
Expand Up @@ -6,7 +6,7 @@ include/stop_slave.inc
CHANGE MASTER TO MASTER_USER= '', MASTER_PASSWORD= '';
START SLAVE;
include/wait_for_slave_io_error.inc [errno=1045, 1593]
include/stop_slave.inc
include/stop_slave_sql.inc
CHANGE MASTER TO MASTER_USER= 'root', MASTER_PASSWORD= '';
START SLAVE;
include/rpl_end.inc
8 changes: 4 additions & 4 deletions mysql-test/suite/rpl/r/rpl_domain_id_filter_io_crash.result
Expand Up @@ -135,7 +135,7 @@ i
2
3
SET @@global.debug_dbug=@saved_dbug;
include/stop_slave.inc
include/stop_slave_sql.inc
DO_DOMAIN_IDS (BEFORE) :
IGNORE_DOMAIN_IDS (BEFORE) :
CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
Expand Down Expand Up @@ -204,7 +204,7 @@ i
10
11
SET @@global.debug_dbug=@saved_dbug;
include/stop_slave.inc
include/stop_slave_sql.inc
DO_DOMAIN_IDS (BEFORE) :
IGNORE_DOMAIN_IDS (BEFORE) : 1
CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
Expand Down Expand Up @@ -287,7 +287,7 @@ i
16
17
SET @@global.debug_dbug=@saved_dbug;
include/stop_slave.inc
include/stop_slave_sql.inc
DO_DOMAIN_IDS (BEFORE) :
IGNORE_DOMAIN_IDS (BEFORE) : 1
CHANGE MASTER TO IGNORE_DOMAIN_IDS=(), MASTER_USE_GTID=slave_pos;
Expand Down Expand Up @@ -384,7 +384,7 @@ i
22
23
SET @@global.debug_dbug=@saved_dbug;
include/stop_slave.inc
include/stop_slave_sql.inc
DO_DOMAIN_IDS (BEFORE) :
IGNORE_DOMAIN_IDS (BEFORE) :
CHANGE MASTER TO IGNORE_DOMAIN_IDS=(1), MASTER_USE_GTID=slave_pos;
Expand Down
5 changes: 3 additions & 2 deletions mysql-test/suite/rpl/r/rpl_gtid_errorlog.result
Expand Up @@ -23,7 +23,8 @@ INSERT INTO t1 VALUES (2);
SET sql_log_bin=1;
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=1062]
include/stop_slave.inc
include/wait_for_slave_io_to_start.inc
include/stop_slave_io.inc
SET GLOBAL gtid_slave_pos= "0-1-100";
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
Expand All @@ -39,7 +40,7 @@ REPLACE INTO t1 VALUES (5);
SET debug_dbug= @dbug_save;
connection slave;
include/wait_for_slave_sql_error.inc [errno=1590]
include/stop_slave.inc
include/stop_slave_io.inc
SET sql_slave_skip_counter=1;
include/start_slave.inc
SELECT * FROM t1 ORDER BY a;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_gtid_startpos.result
Expand Up @@ -36,7 +36,7 @@ CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_USE_GTID=CURRENT_POS;
START SLAVE;
include/wait_for_slave_io_error.inc [errno=1236]
include/stop_slave.inc
include/stop_slave_sql.inc
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT,
MASTER_LOG_FILE="master-bin.000003", MASTER_LOG_POS=4;
include/start_slave.inc
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
Expand Up @@ -226,7 +226,7 @@ connection slave;
call mtr.add_suppression("Slave SQL.*Duplicate entry .1. for key .PRIMARY.. on query.* error.* 1062");
call mtr.add_suppression("Slave SQL.*Request to stop slave SQL Thread received while applying a group that has non-transactional changes; waiting for completion of the group");
Heartbeat events are received while sql thread stopped (1 means 'yes'): 1
include/stop_slave.inc
include/stop_slave_io.inc
DROP TABLE t1;

*** Master send to slave ***
Expand Down
6 changes: 2 additions & 4 deletions mysql-test/suite/rpl/r/rpl_mdev_17614.result
Expand Up @@ -29,8 +29,7 @@ SELECT * FROM t1;
a b c
1 1 1
2 2 3
stop slave;
include/stop_slave.inc
include/stop_slave_io.inc
reset slave;
connection master;
reset master;
Expand Down Expand Up @@ -189,8 +188,7 @@ SELECT * FROM t1;
a b c
1 1 1
2 2 3
stop slave;
include/stop_slave.inc
include/stop_slave_io.inc
reset slave;
connection master;
reset master;
Expand Down
Expand Up @@ -192,7 +192,7 @@ SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/stop_slave_io.inc
include/start_slave.inc
connection master;
connection slave;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_parallel_ignored_errors.result
Expand Up @@ -36,7 +36,7 @@ connection con_temp2;
COMMIT;
connection server_2;
include/wait_for_slave_sql_error.inc [errno=1062]
include/stop_slave.inc
include/stop_slave_io.inc
include/assert.inc [table t1 should have zero rows where a>32]
SELECT * FROM t1 WHERE a>32;
a
Expand Down
Expand Up @@ -191,7 +191,7 @@ SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/stop_slave_io.inc
include/start_slave.inc
connection master;
connection slave;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_row_corruption.result
Expand Up @@ -14,7 +14,7 @@ connection master;
UPDATE t1_11753004, t2_11753004 SET t1_11753004.c1=3, t2_11753004.c1=4 WHERE t1_11753004.c1=1 OR t2_11753004.c1=2;
connection slave;
include/wait_for_slave_sql_error.inc [errno=1593 ]
include/stop_slave.inc
include/stop_slave_io.inc
SET @@global.debug_dbug=@saved_debug;
include/start_slave.inc
connection master;
Expand Down
Expand Up @@ -192,7 +192,7 @@ SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
include/stop_slave.inc
include/stop_slave_io.inc
include/start_slave.inc
connection master;
connection slave;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_stm_start_stop_slave.result
Expand Up @@ -109,7 +109,7 @@ START SLAVE;
include/wait_for_slave_param.inc [Last_IO_Errno]
Last_IO_Errno = '1236'
Last_IO_Error = 'Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the first event 'master-bin.000001' at XXX, the last event read from 'master-bin.000001' at XXX, the last byte read from 'master-bin.000001' at XXX.''
include/stop_slave.inc
include/stop_slave_sql.inc
RESET SLAVE;
connection master;
RESET MASTER;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/semisync_future-7591.result
Expand Up @@ -13,7 +13,7 @@ connection master;
insert into t1 values (1);
reset master;
connection slave;
include/stop_slave.inc
include/stop_slave_sql.inc
reset slave;
include/start_slave.inc
set global rpl_semi_sync_slave_enabled = OFF;
Expand Down
Expand Up @@ -54,7 +54,8 @@ drop table t2;
--source include/start_slave.inc

--echo # wait for T1
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(-1)' and command LIKE 'Slave_worker';
# Wildcard for `state` as it depends on whether WSREP is compiled in or not.
--let $wait_condition= SELECT count(*)=1 FROM information_schema.processlist WHERE state LIKE 'Update_rows_log_event::find_row(%)' and command LIKE 'Slave_worker';
--source include/wait_condition.inc

--echo # wait for T2
Expand All @@ -81,8 +82,9 @@ DROP TABLE t1;
--connection slave
--echo #
--echo # Cleanup
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--let $rpl_allow_error= 1
--source include/wait_for_slave_sql_to_stop.inc
--source include/stop_slave_io.inc
eval set @@global.slave_parallel_threads= $save_slave_parallel_threads;
eval set @@global.slave_parallel_mode= $save_slave_parallel_mode;
eval set @@global.innodb_lock_wait_timeout= $save_innodb_lock_wait_timeout;
Expand Down
3 changes: 1 addition & 2 deletions mysql-test/suite/rpl/t/rpl_connection.test
Expand Up @@ -16,8 +16,7 @@ CHANGE MASTER TO MASTER_USER= '', MASTER_PASSWORD= '';
START SLAVE;
--let $slave_io_errno= 1045, 1593
--source include/wait_for_slave_io_error.inc
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/stop_slave_sql.inc

CHANGE MASTER TO MASTER_USER= 'root', MASTER_PASSWORD= '';
START SLAVE;
Expand Down
9 changes: 4 additions & 5 deletions mysql-test/suite/rpl/t/rpl_domain_id_filter_io_crash.test
Expand Up @@ -149,8 +149,7 @@ connection slave;
SELECT * FROM t1;

SET @@global.debug_dbug=@saved_dbug;
--let $rpl_only_running_threads= 1
--source include/stop_slave.inc
--source include/stop_slave_sql.inc
let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
Expand Down Expand Up @@ -218,7 +217,7 @@ SELECT * FROM t1;

SET @@global.debug_dbug=@saved_dbug;

--source include/stop_slave.inc
--source include/stop_slave_sql.inc
let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
Expand Down Expand Up @@ -286,7 +285,7 @@ SELECT * FROM t1;

SET @@global.debug_dbug=@saved_dbug;

--source include/stop_slave.inc
--source include/stop_slave_sql.inc
let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
Expand Down Expand Up @@ -354,7 +353,7 @@ SELECT * FROM t1;

SET @@global.debug_dbug=@saved_dbug;

--source include/stop_slave.inc
--source include/stop_slave_sql.inc
let $do_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Do_Domain_Ids, 1);
let $ignore_domain_ids_before= query_get_value(SHOW SLAVE STATUS, Replicate_Ignore_Domain_Ids, 1);
--echo DO_DOMAIN_IDS (BEFORE) : $do_domain_ids_before
Expand Down

0 comments on commit ea4bcb9

Please sign in to comment.