| 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 upon a member expel, if auto-rejoin is enabled, |
| 8 |
# the expelled member will try to rejoin the group up to |
| 9 |
# group_replication_autorejoin_tries number of times. It will also verify that, |
| 10 |
# if the rejoining member was a primary before being expelled, when that member |
| 11 |
# is successfully rejoined to the group, it will remain a secondary. |
| 12 |
# |
| 13 |
# Test: |
| 14 |
# 0) The test requires three servers (in single-primary mode). |
| 15 |
# 1) Expel the primary. |
| 16 |
# 2) Verify that the expelled member will try to rejoin the group the number of |
| 17 |
# times it is configured in group_replication_autorejoin_tries sysvar. |
| 18 |
# 3) Verify that it manages to rejoin the group |
| 19 |
# 4) Verify that the newly rejoined member is no longer the primary. |
| 20 |
# 5) Cleanup. |
| 21 |
# |
| 22 |
################################################################################ |
| 23 |
--source include/big_test.inc |
| 24 |
--source include/have_debug_sync.inc |
| 25 |
--source include/linux.inc |
| 26 |
--source include/have_group_replication_plugin.inc |
| 27 |
# |
| 28 |
# We manually start the group because we need to set the rejoin timeout before |
| 29 |
# the START GROUP_REPLICATION command. |
| 30 |
# |
| 31 |
--let $rpl_skip_group_replication_start= 1 |
| 32 |
--let $rpl_server_count = 3 |
| 33 |
--let $rpl_group_replication_single_primary_mode=1 |
| 34 |
--source include/group_replication.inc |
| 35 |
|
| 36 |
--echo |
| 37 |
--echo #### |
| 38 |
--echo # 0) The test requires three servers. |
| 39 |
--echo #### |
| 40 |
--echo |
| 41 |
SET sql_log_bin = 0; |
| 42 |
call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR."); |
| 43 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 44 |
call mtr.add_suppression("Started auto-rejoin procedure attempt*"); |
| 45 |
call mtr.add_suppression("Auto-rejoin procedure attempt*"); |
| 46 |
SET sql_log_bin = 1; |
| 47 |
|
| 48 |
--source include/gr_autorejoin_monitoring.inc |
| 49 |
|
| 50 |
SET @debug_saved = @@GLOBAL.DEBUG; |
| 51 |
SET @@GLOBAL.DEBUG='+d,group_replication_rejoin_short_retry'; |
| 52 |
SET @@GLOBAL.DEBUG='+d,group_replication_stop_before_rejoin'; |
| 53 |
|
| 54 |
--source include/start_and_bootstrap_group_replication.inc |
| 55 |
|
| 56 |
--let $rpl_connection_name = server2 |
| 57 |
--source include/rpl_connection.inc |
| 58 |
|
| 59 |
--source include/start_group_replication.inc |
| 60 |
|
| 61 |
--let $rpl_connection_name = server3 |
| 62 |
--source include/rpl_connection.inc |
| 63 |
|
| 64 |
--source include/start_group_replication.inc |
| 65 |
|
| 66 |
--echo |
| 67 |
--echo #### |
| 68 |
--echo # 1) Expel one of the members. |
| 69 |
--echo #### |
| 70 |
--echo |
| 71 |
--let $rpl_connection_name = server1 |
| 72 |
--source include/rpl_connection.inc |
| 73 |
|
| 74 |
# First, enable auto-rejoin |
| 75 |
SET GLOBAL group_replication_autorejoin_tries = 1; |
| 76 |
|
| 77 |
# Force expel on member 1 |
| 78 |
--let $member_id = `SELECT @@GLOBAL.server_uuid` |
| 79 |
--source include/gr_expel_member_from_group.inc |
| 80 |
|
| 81 |
--echo |
| 82 |
--echo #### |
| 83 |
--echo # 2) Verify that the expelled member will try to rejoin the group the |
| 84 |
--echo # number of it is configured in group_replication_autorejoin_tries |
| 85 |
--echo # sysvar. |
| 86 |
--echo #### |
| 87 |
--echo |
| 88 |
--let $rpl_connection_name = server1 |
| 89 |
--source include/rpl_connection.inc |
| 90 |
|
| 91 |
SET DEBUG_SYNC = "now WAIT_FOR signal.autorejoin_waiting"; |
| 92 |
|
| 93 |
# Wait for the group to stabilize and find a new primary |
| 94 |
--let $rpl_connection_name = server2 |
| 95 |
--source include/rpl_connection.inc |
| 96 |
|
| 97 |
--let $group_replication_number_of_members = 2 |
| 98 |
--source include/gr_wait_for_number_of_members.inc |
| 99 |
|
| 100 |
--let $rpl_connection_name = server3 |
| 101 |
--source include/rpl_connection.inc |
| 102 |
|
| 103 |
--let $group_replication_number_of_members = 2 |
| 104 |
--source include/gr_wait_for_number_of_members.inc |
| 105 |
|
| 106 |
--source include/gr_find_a_primary.inc |
| 107 |
if (!$group_replication_found_primary_out_var) |
| 108 |
{ |
| 109 |
--die "Should have found a primary after member expel!" |
| 110 |
} |
| 111 |
|
| 112 |
--let $rpl_connection_name = server1 |
| 113 |
--source include/rpl_connection.inc |
| 114 |
|
| 115 |
# Verify that auto-rejoin is currently running |
| 116 |
--let $assert_text = Auto-rejoin should be running |
| 117 |
--let $assert_cond = [SELECT IS_AUTOREJOIN_RUNNING()] = TRUE |
| 118 |
--source include/assert.inc |
| 119 |
|
| 120 |
--let $assert_text= super_read_only should be enabled |
| 121 |
--let $assert_cond= [SELECT @@GLOBAL.super_read_only] = 1; |
| 122 |
--source include/assert.inc |
| 123 |
|
| 124 |
# Verify that it attempted one try |
| 125 |
--let $assert_text = We should have attempted 1 rejoin |
| 126 |
--let $assert_cond = [SELECT GET_NUMBER_RETRIES()] = 1 |
| 127 |
--source include/assert.inc |
| 128 |
|
| 129 |
SET DEBUG_SYNC = "now SIGNAL signal.autorejoin_continue"; |
| 130 |
|
| 131 |
# Verify that the auto-rejoin process has terminated |
| 132 |
--let $wait_condition = SELECT IS_AUTOREJOIN_RUNNING() = FALSE |
| 133 |
--source include/wait_condition_or_abort.inc |
| 134 |
|
| 135 |
--echo |
| 136 |
--echo #### |
| 137 |
--echo # 3) Verify that it manages to rejoin the group. |
| 138 |
--echo #### |
| 139 |
--echo |
| 140 |
--let $group_replication_member_state = ONLINE |
| 141 |
--let $group_replication_member_id = $member_id |
| 142 |
--source include/gr_wait_for_member_state.inc |
| 143 |
|
| 144 |
--let $group_replication_number_of_members = 3 |
| 145 |
--source include/gr_wait_for_number_of_members.inc |
| 146 |
|
| 147 |
--let $rpl_connection_name = server2 |
| 148 |
--source include/rpl_connection.inc |
| 149 |
|
| 150 |
--let $group_replication_number_of_members = 3 |
| 151 |
--source include/gr_wait_for_number_of_members.inc |
| 152 |
|
| 153 |
--let $rpl_connection_name = server3 |
| 154 |
--source include/rpl_connection.inc |
| 155 |
|
| 156 |
--let $group_replication_number_of_members = 3 |
| 157 |
--source include/gr_wait_for_number_of_members.inc |
| 158 |
|
| 159 |
--echo |
| 160 |
--echo #### |
| 161 |
--echo # 4) Verify that the newly rejoined member is no longer the primary. |
| 162 |
--echo #### |
| 163 |
--echo |
| 164 |
--let $rpl_connection_name = server1 |
| 165 |
--source include/rpl_connection.inc |
| 166 |
|
| 167 |
--source include/gr_assert_secondary_member.inc |
| 168 |
|
| 169 |
--echo |
| 170 |
--echo #### |
| 171 |
--echo # 5) Cleanup. |
| 172 |
--echo #### |
| 173 |
--echo |
| 174 |
# Stop the GR plugin so that we leave super read-only mode and drop the auto-rejoin monitoring functions |
| 175 |
--source include/stop_group_replication.inc |
| 176 |
|
| 177 |
SET @@GLOBAL.DEBUG = @debug_saved; |
| 178 |
SET @@GLOBAL.group_replication_autorejoin_tries = default; |
| 179 |
--source include/gr_end_autorejoin_monitoring.inc |
| 180 |
--source include/group_replication_end.inc |