--source include/have_binlog_format_statement.inc --let $rpl_topology=1->2 --source include/rpl_init.inc --echo *** MDEV-5509: Incorrect value for Seconds_Behind_Master if parallel replication *** --connection server_2 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; --source include/stop_slave.inc SET GLOBAL slave_parallel_threads=5; --source include/start_slave.inc --connection server_1 CREATE TABLE t1 (a INT PRIMARY KEY, b INT); CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. Statement is unsafe because it uses a system function that may return a different value on the slave"); --save_master_pos --connection server_2 --sync_with_master --connection server_1 INSERT INTO t1 VALUES (1,sleep(2)); --save_master_pos --connection server_2 --sync_with_master # The slave position (which --sync_with_master waits for) is updated just # before the Seconds_Behind_Master. So we have to wait for the zero status # to appear, otherwise there is a small window between --sync_with_master # and SHOW SLAVE STATUS where we can see a non-zero value. --let $slave_param= Seconds_Behind_Master --let $slave_param_value= 0 --source include/wait_for_slave_param.inc --echo Seconds_Behind_Master should be zero here because the slave is fully caught up and idle. --let $status_items= Seconds_Behind_Master --source include/show_slave_status.inc --echo *** MDEV-8294: Inconsistent behavior of slave parallel threads at runtime *** --connection server_1 INSERT INTO t1 VALUES (10,0); # Force a duplicate key error on the slave. SET sql_log_bin= 0; DELETE FROM t1 WHERE a=10; SET sql_log_bin= 1; INSERT INTO t1 VALUES (10,0); --save_master_pos SELECT * FROM t1 WHERE a >= 10 ORDER BY a; --connection server_2 --let $slave_sql_errno= 1062 --source include/wait_for_slave_sql_error.inc # At this point, the worker threads should have stopped also. --let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.processlist WHERE User = "system user" AND State = "Waiting for work from SQL thread"; --source include/wait_condition.inc # Check that the pool can still be resized, but remains inactive as no slave # SQL thread is running. SET GLOBAL slave_parallel_threads=8; --let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.processlist WHERE User = "system user" AND State = "Waiting for work from SQL thread"; --source include/wait_condition.inc STOP SLAVE; # At this point, the worker threads should have stopped. --let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.processlist WHERE User = "system user" AND State = "Waiting for work from SQL thread"; --source include/wait_condition.inc SET GLOBAL sql_slave_skip_counter= 1; --source include/start_slave.inc # At this point, the worker threads should have been spawned. --let $wait_condition= SELECT COUNT(*)=8 FROM information_schema.processlist WHERE User = "system user" AND State = "Waiting for work from SQL thread"; --source include/wait_condition.inc --sync_with_master SELECT * FROM t1 WHERE a >= 10 ORDER BY a; # Clean up --connection server_2 --source include/stop_slave.inc SET GLOBAL slave_parallel_threads=@old_parallel_threads; --source include/start_slave.inc --connection server_1 DROP TABLE t1; --source include/rpl_end.inc