← Back
Editing: gr_exit_state_action_on_applier_error.test
############################################################################### # # group_replication_exit_state_action sysvar specifies which action is taken # by a server once it has involuntarily left the group. Currently there are # only two actions: either the server continues running but with # super_read_only enabled (READ_ONLY) or it aborts (ABORT_SERVER). # # This test shall test that the specified exit action is executed correctly # when an applier error occurs. # # Test: # 0) Setup group of 2 members (M1 and M2). # 1) Force applier error on member 1. # 1.1) Verify that member 1 went to super_read_only mode and changed to ERROR # state. # 2) Relaunch member 1 with exit state action to ABORT_SERVER. # 3) Force applier error again on member 1. # 3.1) Verify that member 1 aborted. # 4) Relaunch member 1. # 5) Cleanup. # ################################################################################ --source include/have_debug.inc --source include/not_valgrind.inc --source include/big_test.inc --source ../inc/have_group_replication_plugin.inc --echo --echo ######################################################################### --echo # 0) Setup group of 2 members (M1 and M2). --echo ######################################################################### --echo --source ../inc/group_replication.inc # Supress log errors since they are expected. SET SESSION sql_log_bin = 0; call mtr.add_suppression("Slave SQL for channel 'group_replication_applier': Could not execute Write_rows event on table test.t1; Duplicate entry.*"); call mtr.add_suppression("Slave SQL for channel 'group_replication_applier': Worker [0-9] failed executing transaction*"); call mtr.add_suppression("Slave SQL for channel 'group_replication_applier': ... The slave coordinator and worker threads are stopped,*"); call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group."); call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group."); call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR."); call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); call mtr.add_suppression("Fatal error during execution of Group Replication"); SET SESSION sql_log_bin = 1; --let $member1_uuid= `SELECT @@GLOBAL.server_uuid` --let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address` --let $group_seeds_server1= `SELECT @@GLOBAL.group_replication_group_seeds` --let $_group_replication_group_whitelist= `SELECT @@GLOBAL.group_replication_ip_whitelist` --echo --echo ######################################################################### --echo # 1) Force applier error on member 1. --echo ######################################################################### --echo # Create a table for our tests --let $rpl_connection_name= server1 --source include/rpl_connection.inc CREATE TABLE t1(a INT PRIMARY KEY); --source include/rpl_sync.inc # Write to it without replicating the trx SET SESSION sql_log_bin= 0; INSERT INTO t1 VALUES (1); SET SESSION sql_log_bin= 1; # Write to the same row on member 2 --let $rpl_connection_name= server2 --source include/rpl_connection.inc INSERT INTO t1 VALUES (1); # The rows on member 2 will be replicated and clash with member 1, thus # generating an applier error --source include/rpl_sync.inc --echo --echo ######################################################################### --echo # 1.1) Verify that member 1 went to super_read_only mode. --echo ######################################################################### --echo # Firstly verify that the member entered an error state --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $group_replication_member_state= ERROR --let $group_replication_member_id= $member1_uuid --source ../inc/gr_wait_for_member_state.inc # Then verify that it enabled super_read_only --let $rpl_connection_name= server1 --source include/rpl_connection.inc --let $assert_text= super_read_only should be enabled --let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1; --source include/assert.inc --echo --echo ######################################################################### --echo # 2) Set exit state action to ABORT_SERVER on member 1. --echo ######################################################################### --echo # Stop GR --source include/stop_group_replication.inc # Delete the transaction that clashed, so the server doesn't error out right # when starting the applier channel. SET sql_log_bin = 0; DELETE FROM t1 WHERE a = 1; SET sql_log_bin = 1; # Set the exit state action sysvar to ABORT_SERVER SET @@GLOBAL.group_replication_exit_state_action = ABORT_SERVER; --echo --echo ######################################################################### --echo # 3) Force applier error again on member 1. --echo ######################################################################### --echo # Inform MTR that we are expecting an abort and that it should wait before # restarting the aborting member --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/start_group_replication.inc # Write to t1 without replicating the trx SET SESSION sql_log_bin= 0; INSERT INTO t1 VALUES (2); SET SESSION sql_log_bin= 1; # Write to the same row on member 2. This will clash with member 1's row and # thus generate an applier error --let $rpl_connection_name= server2 --source include/rpl_connection.inc INSERT INTO t1 VALUES (2); --echo --echo ######################################################################### --echo # 3.1) Verify that member 1 aborted. --echo ######################################################################### --echo # For simplicity, let's assume that once the group size is 1, then member 1 has # abort()'ed --let $group_replication_number_of_members = 1 --source ../inc/gr_wait_for_number_of_members.inc # Also, the member should not be in the group view of any of the other members --let $assert_text = Member 1 should have aborted --let $assert_cond = COUNT(*) = 0 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$member1_uuid" --source include/assert.inc --echo --echo ######################################################################### --echo # 4) Relaunch member 1. --echo ######################################################################### --echo --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/wait_until_disconnected.inc # Inform MTR that it should restart the aborted member --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --let $rpl_server_number= 1 --source include/rpl_reconnect.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc SET SESSION sql_log_bin= 0; DELETE FROM t1 WHERE a = 2; SET SESSION sql_log_bin= 1; --replace_result $group_seeds_server1 GROUP_SEEDS_SERVER1 --eval SET @@global.group_replication_group_seeds="$group_seeds_server1" --replace_result $local_address_server1 LOCAL_ADDRESS_SERVER1 --eval SET @@global.group_replication_local_address="$local_address_server1" --replace_result $_group_replication_group_whitelist GROUP_REPLICATION_GROUP_WHITELIST --eval SET @@global.group_replication_ip_whitelist="$_group_replication_group_whitelist" --source include/start_group_replication.inc --let $group_replication_number_of_members = 2 --source ../inc/gr_wait_for_number_of_members.inc --echo --echo ######################################################################### --echo # 5) Cleanup. --echo ######################################################################### --echo DROP TABLE t1; --source ../inc/group_replication_end.inc
Save File
Cancel