--source include/master-slave.inc
--source include/have_debug_sync.inc
--source include/have_binlog_format_statement.inc

call mtr.add_suppression("Slave SQL: Request to stop slave SQL Thread received while applying a group that has non-transactional changes");

--let $rpl_connection_name=slave_lock
--let $rpl_server_number=2
--source include/rpl_connect.inc

--let $rpl_connection_name=slave_nolock
--let $rpl_server_number=2
--source include/rpl_connect.inc

--let $show_statement= SHOW PROCESSLIST
--let $field= Info

connection master;
--echo [master]
--disable_warnings
DROP TABLE IF EXISTS t;
--enable_warnings
CREATE TABLE t(id INT);
sync_slave_with_master;

connection slave;
--echo [slave]
SET DEBUG_SYNC='RESET';
SET GLOBAL DEBUG="+d,after_mysql_insert,after_show_slave_status";

connection master;
--echo [master]
INSERT INTO t VALUES(0);

connection slave;
--echo [slave]
--let $condition= 'INSERT INTO t VALUES(0)'
--source include/wait_show_condition.inc

--echo check 'SHOW SLAVE STATUS' and 'SHOW SLAVE STATUS NOLOCK' - both should work fine
--source include/percona_show_slave_status_nolock.inc

connection master;
--echo [master]
INSERT INTO t VALUES(1);

connection slave;
--echo [slave]
--let $condition= 'INSERT INTO t VALUES(1)'
--source include/wait_show_condition.inc

--let $rpl_connection_name=slave_stop
--let $rpl_server_number=2
--source include/rpl_connect.inc

connection slave_stop;
--echo [slave_stop]
send STOP SLAVE;

connection slave;
--echo [slave]
--let $condition= 'STOP SLAVE'
--source include/wait_show_condition.inc

--echo check 'SHOW SLAVE STATUS' and 'SHOW SLAVE STATUS NOLOCK' - just NOLOCK version should works fine
--source include/percona_show_slave_status_nolock.inc


connection slave_stop;
--echo [slave_stop]
reap;
--source include/wait_for_slave_to_stop.inc
START SLAVE;
--source include/wait_for_slave_to_start.inc

connection master;
--echo [master]
SET DEBUG_SYNC='RESET';

connection slave;
--echo [slave]
SET GLOBAL DEBUG='';
SET DEBUG_SYNC='RESET';

connection master;
--echo [master]
DROP TABLE t;
sync_slave_with_master;

--source include/rpl_end.inc
