# # Test case to verify that asynchronous replication channel SQL and IO threads # are also stopped when group replication is stopped. # # Test: # # 0. The test requires two servers: M1 and M2. # 1. Setup Group Replication on server 1. # 2. Create new channel ch2_1: server1(slave), server2(master). # 3. Add some data to server2. # 4. Verify data is replicated to server1. # 5. Activate group_replication_stop_all_channels_failure # debug sync point, which will return # ER_GROUP_REPLICATION_COMMAND_FAILURE error, when stop # group replication calls to stop all replication channels. # 5.1. Stop Group Replication # 5.2. Verify member is OFFLINE # 5.3. Verify occurrence of error message # 6. Add some more data to server2. # 7. Verify channel ch2_1 IO and SQL THREADS are OFF. # 8. Verify data isn't replicated to group i.e. server1. # 9. Clean up. # --source include/have_debug.inc --source include/have_group_replication_plugin.inc --let $rpl_skip_group_replication_start= 1 --source include/group_replication.inc --echo --echo ############################################################ --echo # 1. Setup Group Replication on server 1. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_and_bootstrap_group_replication.inc --echo --echo ############################################################ --echo # 2. Setup a asynchronous replication connection from server 2 --echo # into group (server 1) --let $rpl_connection_name= server1 --source include/rpl_connection.inc --replace_result $SERVER_MYPORT_2 SERVER_2_PORT --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_AUTO_POSITION=1 for channel 'ch2_1' --source include/start_slave.inc --echo --echo ############################################################ --echo # 3. Execute some transactions on server 2. --let $rpl_connection_name= server2 --source include/rpl_connection.inc CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; INSERT INTO t1 VALUES (0); --echo --echo ############################################################ --echo # 4. Wait until transactions executed on server 2 are applied --echo # on group. --let $sync_slave_connection= server1 --let $rpl_channel_name=ch2_1 --source include/sync_slave_sql_with_master.inc --echo --echo ############################################################ --echo # 5. Activate group_replication_stop_all_channels_failure --echo # debug sync point, which will return --echo # ER_GROUP_REPLICATION_COMMAND_FAILURE error, when stop --echo # group replication calls to stop all replication channels. --let $rpl_connection_name= server1 --source include/rpl_connection.inc --echo # 5.1. Stop Group Replication # Stop group replication will error out, but this will not stop bringing # member to OFFLINE mode SET @debug_save= @@GLOBAL.DEBUG; SET @@GLOBAL.DEBUG='d,group_replication_stop_all_channels_failure'; --error ER_GROUP_REPLICATION_COMMAND_FAILURE STOP GROUP_REPLICATION; SET @@GLOBAL.DEBUG= @debug_save; --echo # 5.2. Verify member is OFFLINE --let $group_replication_member_state= OFFLINE --source include/gr_wait_for_member_state.inc --echo # 5.3. Verify occurrence of error message --replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][-+Z][0-9:]* *[0-9]* *\[/DATE_TIME [/ --let $grep_file= $MYSQLTEST_VARDIR/tmp/gr_stop_async_on_stop_gr.err --let $grep_pattern= Error stopping channel: ch2_1. Got error: 1, Error_code: MY-000001 --let $grep_output= print_count --source include/grep_pattern.inc --let $grep_file= $MYSQLTEST_VARDIR/tmp/gr_stop_async_on_stop_gr.err --let $grep_pattern= Error stopping channel: . Got error: 1, Error_code: MY-000001 --let $grep_output= print_count --source include/grep_pattern.inc --echo --echo ############################################################ --echo # 6. Execute data on server 2 and ensure it is not accepted on server 1. --let $rpl_connection_name= server2 --source include/rpl_connection.inc INSERT INTO t1 VALUES (1); --echo --echo ############################################################ --echo # 7. Verify channel ch2_1 IO and SQL THREADS are OFF --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $rpl_channel_name='ch2_1' --let $slave_io_errno= 1 --source include/wait_for_slave_to_stop.inc --let $rpl_channel_name= --let $assert_text= Verify channel ch2_1 IO_THREAD is OFF --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch2_1\', SERVICE_STATE, 1]" = "OFF" --source include/assert.inc --let $assert_text= Verify channel ch2_1 SQL_THREAD is OFF --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch2_1\', SERVICE_STATE, 1]" = "OFF" --source include/assert.inc --echo --echo ############################################################ --echo # 8. Verify data isn't replicated to group i.e. server1 --let $assert_text= 'There is no value 1 in table t1' --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0 --source include/assert.inc --echo --echo ############################################################ --echo # 9. Clean Up --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET GLOBAL read_only= 0; RESET SLAVE ALL FOR CHANNEL 'ch2_1'; DROP TABLE test.t1; --let $rpl_connection_name= server2 --source include/rpl_connection.inc DROP TABLE test.t1; --source include/group_replication_end.inc