| 1 |
############################################################################### |
| 2 |
# |
| 3 |
# group_replication_exit_state_action sysvar specifies which action is taken by |
| 4 |
# a server once it has involuntarily left the group. Currently there are only |
| 5 |
# two actions: either the server continues running but with super_read_only |
| 6 |
# enabled (READ_ONLY) or it aborts (ABORT_SERVER). |
| 7 |
# |
| 8 |
# This test shall verify that the correct exit state action is executed when |
| 9 |
# an error occurs during the catch-up phase of distributed recovery. |
| 10 |
# |
| 11 |
# Test: |
| 12 |
# 0) Setup group of 2 members (M1 and M2). |
| 13 |
# 1) Force error during the catch-up phase of M1. |
| 14 |
# 1.1) Verify that M1 goes into ERROR state and to super_read_only mode. |
| 15 |
# 2) Set group_replication_exit_state_action to ABORT_SERVER on M1. |
| 16 |
# 3) Force another error during the catch-up phase of M1. |
| 17 |
# 3.1) Verify that M1 aborted. |
| 18 |
# 4) Relaunch M1 and join the group. |
| 19 |
# 5) Cleanup. |
| 20 |
# |
| 21 |
################################################################################ |
| 22 |
--source include/big_test.inc |
| 23 |
--source include/have_group_replication_plugin.inc |
| 24 |
|
| 25 |
--echo |
| 26 |
--echo ######################################################################### |
| 27 |
--echo # 0) Setup group of 2 members (M1 and M2) but only start GR on M2. |
| 28 |
--echo ######################################################################### |
| 29 |
--echo |
| 30 |
--let $rpl_skip_group_replication_start= 1 |
| 31 |
--source include/group_replication.inc |
| 32 |
--let $rpl_connection_name= server1 |
| 33 |
--source include/rpl_connection.inc |
| 34 |
--let $member1_uuid= `SELECT @@GLOBAL.server_uuid` |
| 35 |
--let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address` |
| 36 |
--let $group_seeds_server1= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 37 |
# Create a table on M1 while it isn't part of the group |
| 38 |
SET sql_log_bin = 0; |
| 39 |
CREATE TABLE t1 (a INT PRIMARY KEY); |
| 40 |
INSERT INTO t1 VALUES (1); |
| 41 |
SET sql_log_bin = 1; |
| 42 |
# Bootstrap the rest of the group (minus M1) |
| 43 |
--let $rpl_connection_name= server2 |
| 44 |
--source include/rpl_connection.inc |
| 45 |
--source include/start_and_bootstrap_group_replication.inc |
| 46 |
# Suppress expected errors and warnings |
| 47 |
--let $rpl_connection_name= server1 |
| 48 |
--source include/rpl_connection.inc |
| 49 |
SET sql_log_bin = 0; |
| 50 |
call mtr.add_suppression("read failed"); |
| 51 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': Error 'Table 't1'*"); |
| 52 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': Worker [0-9] failed executing transaction*"); |
| 53 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_recovery': ... The replica coordinator and worker threads are stopped,*"); |
| 54 |
call mtr.add_suppression("Replica: Table 't1' already exists Error_code:*"); |
| 55 |
call mtr.add_suppression("Maximum number of retries when trying to connect to a donor reached. Aborting group replication incremental recovery."); |
| 56 |
call mtr.add_suppression("Fatal error during the incremental recovery process of Group Replication. The server will leave the group."); |
| 57 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 58 |
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going."); |
| 59 |
call mtr.add_suppression("The plugin encountered a critical error and will abort: Fatal error in the recovery module of Group Replication."); |
| 60 |
call mtr.add_suppression("Error while starting the group replication incremental recovery receiver/applier threads"); |
| 61 |
SET sql_log_bin = 1; |
| 62 |
|
| 63 |
--echo |
| 64 |
--echo ######################################################################### |
| 65 |
--echo # 1) Force error during the catch-up phase of M1. |
| 66 |
--echo ######################################################################### |
| 67 |
--echo |
| 68 |
# Create and replicate a table on the group |
| 69 |
--let $rpl_connection_name= server2 |
| 70 |
--source include/rpl_connection.inc |
| 71 |
CREATE TABLE t1 (a INT PRIMARY KEY); |
| 72 |
# Add M1 to the group |
| 73 |
--let $rpl_connection_name= server1 |
| 74 |
--source include/rpl_connection.inc |
| 75 |
--let $group_replication_start_member_state= ERROR |
| 76 |
--source include/start_group_replication.inc |
| 77 |
|
| 78 |
--echo |
| 79 |
--echo ######################################################################### |
| 80 |
--echo # 1.1) Verify that M1 goes into ERROR state and to super_read_only mode. |
| 81 |
--echo ######################################################################### |
| 82 |
--echo |
| 83 |
# Firstly verify that the member entered an error state |
| 84 |
--let $group_replication_member_state= ERROR |
| 85 |
--let $group_replication_member_id= $member1_uuid |
| 86 |
--source include/gr_wait_for_member_state.inc |
| 87 |
# Then verify that it enabled super_read_only |
| 88 |
--let $rpl_connection_name= server1 |
| 89 |
--source include/rpl_connection.inc |
| 90 |
--let $assert_text= super_read_only should be enabled |
| 91 |
--let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1; |
| 92 |
--source include/assert.inc |
| 93 |
# Lastly, verify that the member is not viewed as part of the group on M2 and |
| 94 |
# M3 |
| 95 |
--let $rpl_connection_name= server2 |
| 96 |
--source include/rpl_connection.inc |
| 97 |
--let $group_replication_number_of_members= 1 |
| 98 |
--source include/gr_wait_for_number_of_members.inc |
| 99 |
|
| 100 |
--echo |
| 101 |
--echo ######################################################################### |
| 102 |
--echo # 2) Set group_replication_exit_state_action to ABORT_SERVER on M1. |
| 103 |
--echo ######################################################################### |
| 104 |
--echo |
| 105 |
# Stop GR |
| 106 |
--let $rpl_connection_name= server1 |
| 107 |
--source include/rpl_connection.inc |
| 108 |
--source include/stop_group_replication.inc |
| 109 |
|
| 110 |
# Set the exit state action sysvar to ABORT_SERVER |
| 111 |
SET @@GLOBAL.group_replication_exit_state_action = ABORT_SERVER; |
| 112 |
|
| 113 |
--echo |
| 114 |
--echo ######################################################################### |
| 115 |
--echo # 3) Force another error during the catch-up phase of M1. |
| 116 |
--echo ######################################################################### |
| 117 |
--echo |
| 118 |
# Inform MTR that we are expecting an abort and that it should wait before |
| 119 |
# restarting the aborting member |
| 120 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 121 |
|
| 122 |
# Join the group again |
| 123 |
--let $group_replication_start_member_state= ERROR |
| 124 |
--source include/start_group_replication.inc |
| 125 |
|
| 126 |
--echo |
| 127 |
--echo ######################################################################### |
| 128 |
--echo # 3.1) Verify that M1 aborted. |
| 129 |
--echo ######################################################################### |
| 130 |
--echo |
| 131 |
# For simplicity, let's assume that once the group size is 1, then member 1 has |
| 132 |
# abort()'ed |
| 133 |
--let $rpl_connection_name= server2 |
| 134 |
--source include/rpl_connection.inc |
| 135 |
--let $group_replication_number_of_members = 1 |
| 136 |
--source include/gr_wait_for_number_of_members.inc |
| 137 |
# Also, the member should not be in the group view of any of the other members |
| 138 |
--let $assert_text = Member 1 should have aborted |
| 139 |
--let $assert_cond = COUNT(*) = 0 FROM performance_schema.replication_group_members WHERE MEMBER_ID = "$member1_uuid" |
| 140 |
--source include/assert.inc |
| 141 |
|
| 142 |
--echo |
| 143 |
--echo ######################################################################### |
| 144 |
--echo # 4) Relaunch M1 and join the group. |
| 145 |
--echo ######################################################################### |
| 146 |
--echo |
| 147 |
--let $rpl_connection_name= server1 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
--source include/wait_until_disconnected.inc |
| 150 |
# Inform MTR that it should restart the aborted member |
| 151 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 152 |
# Reconnect |
| 153 |
--let $rpl_server_number= 1 |
| 154 |
--source include/rpl_reconnect.inc |
| 155 |
--let $rpl_connection_name= server1 |
| 156 |
--source include/rpl_connection.inc |
| 157 |
# Remove conflicting trx so M1 can stay in the group |
| 158 |
SET SESSION sql_log_bin= 0; |
| 159 |
DROP TABLE t1; |
| 160 |
SET SESSION sql_log_bin= 1; |
| 161 |
RESET MASTER; |
| 162 |
--replace_result $group_seeds_server1 GROUP_SEEDS_SERVER1 |
| 163 |
--eval SET @@global.group_replication_group_seeds="$group_seeds_server1" |
| 164 |
--replace_result $local_address_server1 LOCAL_ADDRESS_SERVER1 |
| 165 |
--eval SET @@global.group_replication_local_address="$local_address_server1" |
| 166 |
--source include/start_group_replication.inc |
| 167 |
# Wait for group to stabilize |
| 168 |
--let $group_replication_number_of_members = 2 |
| 169 |
--source include/gr_wait_for_number_of_members.inc |
| 170 |
|
| 171 |
--echo |
| 172 |
--echo ######################################################################### |
| 173 |
--echo # 5) Cleanup. |
| 174 |
--echo ######################################################################### |
| 175 |
--echo |
| 176 |
DROP TABLE t1; |
| 177 |
|
| 178 |
--source include/group_replication_end.inc |