| 1 |
################################################################################ |
| 2 |
# |
| 3 |
# The auto-rejoin process is a mechanism that allows a server that left the |
| 4 |
# group due to flaky network (either on his side or on the other members) to |
| 5 |
# try to join again up to group_replication_autorejoin_tries number of times. |
| 6 |
# |
| 7 |
# This test shall verify that if a concurrent error to autorejoin happens, the |
| 8 |
# member will preserve its ERROR state. |
| 9 |
# |
| 10 |
# Test: |
| 11 |
# 0) The test requires three servers. |
| 12 |
# 1) Add a local transaction to server1 so that it does fail on rejoin. |
| 13 |
# 2) Provoke a majority loss. |
| 14 |
# 3) Verify that the member in the partitioned group will try to rejoin the |
| 15 |
# group the number of it is configured in |
| 16 |
# group_replication_autorejoin_tries sysvar. |
| 17 |
# 4) Verify that once it rejoins the applier error is triggered and member |
| 18 |
# remains in ERROR state. |
| 19 |
# 5) Cleanup. |
| 20 |
# |
| 21 |
################################################################################ |
| 22 |
--source include/have_debug_sync.inc |
| 23 |
--source include/big_test.inc |
| 24 |
--source include/have_group_replication_plugin.inc |
| 25 |
# |
| 26 |
# We manually start the group because we need to set the rejoin timeout before |
| 27 |
# the START GROUP_REPLICATION command. |
| 28 |
# |
| 29 |
--let $rpl_skip_group_replication_start= 1 |
| 30 |
--let $rpl_server_count = 3 |
| 31 |
--source include/group_replication.inc |
| 32 |
|
| 33 |
--echo |
| 34 |
--echo #### |
| 35 |
--echo # 0) The test requires three servers. |
| 36 |
--echo #### |
| 37 |
--echo |
| 38 |
SET SESSION sql_log_bin = 0; |
| 39 |
call mtr.add_suppression("This member could not reach a majority of the members for more than 10 seconds. The member will now leave the group as instructed by the group_replication_unreachable_majority_timeout option"); |
| 40 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 41 |
call mtr.add_suppression("\\[GCS\\] Timeout while waiting for the group communication engine to exit!"); |
| 42 |
call mtr.add_suppression("\\[GCS\\] The member has failed to gracefully leave the group."); |
| 43 |
call mtr.add_suppression("Started auto-rejoin procedure attempt*"); |
| 44 |
call mtr.add_suppression("Auto-rejoin procedure attempt*"); |
| 45 |
call mtr.add_suppression("Unable to initialize the Group Replication applier module."); |
| 46 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Could not execute Update_rows event on table test.t1; Duplicate entry '1' for key 't1.PRIMARY'.*"); |
| 47 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Worker .* failed executing transaction .*; Could not execute Update_rows event on table test.t1; Duplicate entry '1' for key 't1.PRIMARY'*"); |
| 48 |
call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped,*"); |
| 49 |
call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group."); |
| 50 |
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group."); |
| 51 |
call mtr.add_suppression("Unable to confirm whether the server has left the group or not. Check performance_schema.replication_group_members to check group membership information."); |
| 52 |
SET SESSION sql_log_bin = 1; |
| 53 |
|
| 54 |
--source include/gr_autorejoin_monitoring.inc |
| 55 |
|
| 56 |
SET @debug_saved = @@GLOBAL.DEBUG; |
| 57 |
SET @@GLOBAL.DEBUG='+d,group_replication_rejoin_short_retry'; |
| 58 |
SET @@GLOBAL.DEBUG='+d,group_replication_stop_before_rejoin_loop'; |
| 59 |
|
| 60 |
--source include/start_and_bootstrap_group_replication.inc |
| 61 |
CREATE TABLE t1(a INT PRIMARY KEY); |
| 62 |
|
| 63 |
--let $rpl_connection_name = server2 |
| 64 |
--source include/rpl_connection.inc |
| 65 |
|
| 66 |
--source include/start_group_replication.inc |
| 67 |
--let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` |
| 68 |
--let $group_seeds_server2= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 69 |
|
| 70 |
--let $rpl_connection_name = server3 |
| 71 |
--source include/rpl_connection.inc |
| 72 |
|
| 73 |
--source include/start_group_replication.inc |
| 74 |
--let $local_address_server3= `SELECT @@GLOBAL.group_replication_local_address` |
| 75 |
|
| 76 |
--echo |
| 77 |
--echo #### |
| 78 |
--echo # 1) Add a local transaction to server1 so that it does fail on rejoin. |
| 79 |
--echo #### |
| 80 |
--let $rpl_connection_name = server1 |
| 81 |
--source include/rpl_connection.inc |
| 82 |
SET @@GLOBAL.DEBUG='+d,block_applier_updates'; |
| 83 |
|
| 84 |
--let $rpl_connection_name = server2 |
| 85 |
--source include/rpl_connection.inc |
| 86 |
INSERT INTO t1 VALUES(0); |
| 87 |
UPDATE t1 SET a=1 WHERE a=0; |
| 88 |
|
| 89 |
--let $rpl_connection_name = server3 |
| 90 |
--source include/rpl_connection.inc |
| 91 |
--let $wait_condition= SELECT @@GLOBAL.GTID_EXECUTED = "$group_replication_group_name:1-6" |
| 92 |
--source include/wait_condition.inc |
| 93 |
|
| 94 |
--let $rpl_connection_name = server1 |
| 95 |
--source include/rpl_connection.inc |
| 96 |
--let $wait_condition= SELECT received_transaction_set="$group_replication_group_name:1-6" FROM performance_schema.replication_connection_status WHERE channel_name="group_replication_applier"; |
| 97 |
--source include/wait_condition.inc |
| 98 |
|
| 99 |
SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked"; |
| 100 |
|
| 101 |
# Cause a applier error during recovery when plugins tries to rejoin. |
| 102 |
SET SESSION sql_log_bin= 0; |
| 103 |
INSERT INTO t1 VALUES(1); |
| 104 |
SET SESSION sql_log_bin= 1; |
| 105 |
|
| 106 |
--echo |
| 107 |
--echo #### |
| 108 |
--echo # 2) Provoke a majority loss. |
| 109 |
--echo #### |
| 110 |
--echo |
| 111 |
--let $rpl_connection_name = server1 |
| 112 |
--source include/rpl_connection.inc |
| 113 |
|
| 114 |
SET GLOBAL group_replication_autorejoin_tries = 1; |
| 115 |
|
| 116 |
# Provoke a majority loss on member 1 |
| 117 |
--let $member_id = `SELECT @@GLOBAL.server_uuid` |
| 118 |
--source include/gr_provoke_majority_loss.inc |
| 119 |
|
| 120 |
SET DEBUG_SYNC = "now WAIT_FOR signal.autorejoin_entering_loop"; |
| 121 |
|
| 122 |
--echo |
| 123 |
--echo #### |
| 124 |
--echo # 3) Verify that the member in the partitioned group will try to rejoin the |
| 125 |
--echo # group the number of it is configured in |
| 126 |
--echo # group_replication_autorejoin_tries sysvar. |
| 127 |
--echo #### |
| 128 |
--let $rpl_server_number= 2 |
| 129 |
--source include/rpl_reconnect.inc |
| 130 |
|
| 131 |
--let $rpl_connection_name= server2 |
| 132 |
--source include/rpl_connection.inc |
| 133 |
|
| 134 |
--replace_result $group_seeds_server2 GROUP_SEEDS_SERVER2 |
| 135 |
--eval SET @@global.group_replication_group_seeds="$group_seeds_server2" |
| 136 |
--replace_result $local_address_server2 LOCAL_ADDRESS_SERVER2 |
| 137 |
--eval SET @@global.group_replication_local_address="$local_address_server2" |
| 138 |
--source include/start_and_bootstrap_group_replication.inc |
| 139 |
|
| 140 |
--let $rpl_server_number= 3 |
| 141 |
--source include/rpl_reconnect.inc |
| 142 |
|
| 143 |
--let $rpl_connection_name= server3 |
| 144 |
--source include/rpl_connection.inc |
| 145 |
|
| 146 |
--replace_result $local_address_server2 LOCAL_ADDRESS_SERVER2 |
| 147 |
--eval SET @@global.group_replication_group_seeds="$local_address_server2" |
| 148 |
--replace_result $local_address_server3 LOCAL_ADDRESS_SERVER3 |
| 149 |
--eval SET @@global.group_replication_local_address="$local_address_server3" |
| 150 |
--source include/start_group_replication.inc |
| 151 |
|
| 152 |
--let $rpl_connection_name = server2 |
| 153 |
--source include/rpl_connection.inc |
| 154 |
--let $group_replication_number_of_members = 2 |
| 155 |
--source include/gr_wait_for_number_of_members.inc |
| 156 |
--let $rpl_connection_name = server3 |
| 157 |
--source include/rpl_connection.inc |
| 158 |
--let $group_replication_number_of_members = 2 |
| 159 |
--source include/gr_wait_for_number_of_members.inc |
| 160 |
|
| 161 |
--let $rpl_connection_name = server1 |
| 162 |
--source include/rpl_connection.inc |
| 163 |
|
| 164 |
SET DEBUG_SYNC = "now SIGNAL signal.autorejoin_enter_loop"; |
| 165 |
|
| 166 |
# When the stop applier step of autorejoin is waiting, resume the applier. |
| 167 |
# The applier will be stopped before the UPDATE statement is committed. |
| 168 |
--let $gr_applier_module_thread_id= `SELECT THREAD_ID FROM performance_schema.threads WHERE NAME like 'thread/group_rpl/THD_applier_module_receiver'` |
| 169 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_waits_current WHERE THREAD_ID=$gr_applier_module_thread_id AND EVENT_NAME='wait/synch/cond/sql/Relay_log_info::stop_cond' AND TIMER_WAIT != 'NULL' |
| 170 |
--source include/wait_condition.inc |
| 171 |
|
| 172 |
SET @@GLOBAL.DEBUG='-d,block_applier_updates'; |
| 173 |
SET DEBUG_SYNC = "now SIGNAL resume_applier_read"; |
| 174 |
|
| 175 |
--echo |
| 176 |
--echo #### |
| 177 |
--echo # 4) Verify that once it rejoins the applier error is triggered and member |
| 178 |
--echo # remains in ERROR state. |
| 179 |
--echo #### |
| 180 |
--echo |
| 181 |
|
| 182 |
--let $group_replication_member_state = ERROR |
| 183 |
--let $group_replication_member_id = $member_id |
| 184 |
--source include/gr_wait_for_member_state.inc |
| 185 |
|
| 186 |
--let $wait_condition = SELECT IS_AUTOREJOIN_RUNNING() = FALSE |
| 187 |
--source include/wait_condition.inc |
| 188 |
|
| 189 |
--echo |
| 190 |
--echo #### |
| 191 |
--echo # 5) Cleanup. |
| 192 |
--echo #### |
| 193 |
--echo |
| 194 |
--let $rpl_connection_name = server1 |
| 195 |
--source include/rpl_connection.inc |
| 196 |
|
| 197 |
--source include/stop_group_replication.inc |
| 198 |
SET SESSION sql_log_bin= 0; |
| 199 |
DROP TABLE t1; |
| 200 |
SET SESSION sql_log_bin= 1; |
| 201 |
RESET SLAVE ALL FOR CHANNEL "group_replication_applier"; |
| 202 |
SET @@GLOBAL.DEBUG = @debug_saved; |
| 203 |
SET DEBUG_SYNC= 'RESET'; |
| 204 |
SET @@GLOBAL.group_replication_autorejoin_tries = default; |
| 205 |
--source include/gr_end_autorejoin_monitoring.inc |
| 206 |
|
| 207 |
--let $rpl_connection_name = server2 |
| 208 |
--source include/rpl_connection.inc |
| 209 |
DROP TABLE t1; |
| 210 |
|
| 211 |
--source include/group_replication_end.inc |