| 1 |
############################################################################### |
| 2 |
# This test verifies that cloning works when the member auto rejoins the group |
| 3 |
# after an issue. |
| 4 |
# |
| 5 |
# 0. This test requires 3 servers server1, server2, server3 |
| 6 |
# 1. Install clone plugin on server1. |
| 7 |
# 2. Bootstrap server1 and add some data |
| 8 |
# 3. Install the clone plugin and start GR on server3 |
| 9 |
# 4. Restart server 2 with a monitoring process (mysqld_safe) |
| 10 |
# 5. Setup server2 so group replication starts on boot |
| 11 |
# Install the Clone plugin |
| 12 |
# 6. On a empty server2 start group replication |
| 13 |
# Wait for it to restart and come back |
| 14 |
# Check clone was completed |
| 15 |
# 7. Get server2 expelled |
| 16 |
# 8. Add more data to server 1 before server2 rejoins |
| 17 |
# 9. Unblock the rejoin, another clone should happen |
| 18 |
# 10. Cleanup |
| 19 |
# |
| 20 |
|
| 21 |
--source include/big_test.inc |
| 22 |
--source include/have_debug_sync.inc |
| 23 |
--source include/linux.inc |
| 24 |
--source include/have_mysqld_monitoring_process.inc |
| 25 |
--source include/have_clone_plugin.inc |
| 26 |
--source include/have_group_replication_plugin.inc |
| 27 |
--let $rpl_server_count= 3 |
| 28 |
--let $rpl_skip_group_replication_start= 1 |
| 29 |
--source include/group_replication.inc |
| 30 |
|
| 31 |
# Validate plugins |
| 32 |
--let plugins = CLONE_PLUGIN,GROUP_REPLICATION |
| 33 |
--source include/check_plugin_dir.inc |
| 34 |
|
| 35 |
--echo |
| 36 |
--echo ############################################################ |
| 37 |
--echo # 1. Install clone plugin on server1. |
| 38 |
|
| 39 |
--let $rpl_connection_name= server1 |
| 40 |
--source include/rpl_connection.inc |
| 41 |
--let $server1_port= `SELECT @@GLOBAL.PORT` |
| 42 |
|
| 43 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 44 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 45 |
|
| 46 |
--echo |
| 47 |
--echo ############################################################ |
| 48 |
--echo # 2. Bootstrap server1 and add some data |
| 49 |
|
| 50 |
--source include/start_and_bootstrap_group_replication.inc |
| 51 |
|
| 52 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 53 |
INSERT INTO t1 VALUES (1); |
| 54 |
INSERT INTO t1 VALUES (2); |
| 55 |
|
| 56 |
--echo |
| 57 |
--echo ################################################################# |
| 58 |
--echo # 3. Install the clone plugin and start GR on server3 |
| 59 |
--let $rpl_connection_name= server3 |
| 60 |
--source include/rpl_connection.inc |
| 61 |
|
| 62 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 63 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 64 |
|
| 65 |
--source include/start_group_replication.inc |
| 66 |
|
| 67 |
--echo |
| 68 |
--echo ############################################################## |
| 69 |
--echo # 4. Restart server 2 with a monitoring process (mysqld_safe) |
| 70 |
|
| 71 |
--let $rpl_connection_name= server2 |
| 72 |
--source include/rpl_connection.inc |
| 73 |
|
| 74 |
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 75 |
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 76 |
--let $_group_replication_comm_stack= `SELECT @@GLOBAL.group_replication_communication_stack` |
| 77 |
|
| 78 |
# after the restart with mysqld_safe we need this option for expel operations |
| 79 |
SET PERSIST local_infile= ON; |
| 80 |
|
| 81 |
--let $plugin_list= $GROUP_REPLICATION |
| 82 |
--source include/spawn_monitoring_process.inc |
| 83 |
|
| 84 |
--echo |
| 85 |
--echo ############################################################ |
| 86 |
--echo # 5. Setup server2 so group replication starts on boot |
| 87 |
--echo # Install the Clone plugin |
| 88 |
|
| 89 |
--disable_query_log |
| 90 |
--eval SET PERSIST group_replication_group_name= "$group_replication_group_name" |
| 91 |
--eval SET PERSIST group_replication_local_address= "$_group_replication_local_address" |
| 92 |
--eval SET PERSIST group_replication_group_seeds= "$_group_replication_group_seeds" |
| 93 |
--eval SET PERSIST group_replication_communication_stack= "$_group_replication_comm_stack" |
| 94 |
|
| 95 |
SET PERSIST group_replication_start_on_boot= ON; |
| 96 |
--enable_query_log |
| 97 |
|
| 98 |
--replace_result $CLONE_PLUGIN CLONE_PLUGIN |
| 99 |
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN' |
| 100 |
|
| 101 |
--echo |
| 102 |
--echo ############################################################ |
| 103 |
--echo # 6. On a empty server2 start group replication |
| 104 |
--echo # Wait for it to restart and come back |
| 105 |
--echo # Check clone was completed |
| 106 |
|
| 107 |
--let $_group_replication_threshold_save= `SELECT @@GLOBAL.group_replication_clone_threshold` |
| 108 |
SET GLOBAL group_replication_clone_threshold= 1; |
| 109 |
|
| 110 |
START GROUP_REPLICATION; |
| 111 |
|
| 112 |
--source include/wait_until_disconnected.inc |
| 113 |
|
| 114 |
--let $rpl_server_number= 2 |
| 115 |
--source include/rpl_reconnect.inc |
| 116 |
|
| 117 |
--let $group_replication_member_state=ONLINE |
| 118 |
--source include/gr_wait_for_member_state.inc |
| 119 |
|
| 120 |
--let $assert_text= Clone must be completed |
| 121 |
--let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1; |
| 122 |
--source include/assert.inc |
| 123 |
|
| 124 |
# See if the data has been properly cloned in server2 |
| 125 |
--let $diff_tables=server1:test.t1, server2:test.t1, server3:test.t1 |
| 126 |
--source include/diff_tables.inc |
| 127 |
|
| 128 |
--echo |
| 129 |
--echo ############################################################ |
| 130 |
--echo # 7. Get server2 expelled |
| 131 |
|
| 132 |
--let $rpl_connection_name = server2 |
| 133 |
--source include/rpl_connection.inc |
| 134 |
|
| 135 |
SET @debug_saved = @@GLOBAL.DEBUG; |
| 136 |
SET @@GLOBAL.DEBUG='+d,group_replication_stop_before_rejoin'; |
| 137 |
|
| 138 |
# First, enable auto-rejoin |
| 139 |
SET GLOBAL group_replication_autorejoin_tries = 1; |
| 140 |
|
| 141 |
# Force expel on member 2 |
| 142 |
--let $member_id = `SELECT @@GLOBAL.server_uuid` |
| 143 |
--source include/gr_expel_member_from_group.inc |
| 144 |
|
| 145 |
SET DEBUG_SYNC = "now WAIT_FOR signal.autorejoin_waiting"; |
| 146 |
|
| 147 |
# Verify that it is currently running |
| 148 |
--let $assert_text = Auto-rejoin should be running |
| 149 |
--let $assert_count_var = `SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE EVENT_NAME LIKE '%auto-rejoin%'` |
| 150 |
--let $assert_cond = $assert_count_var = 1 |
| 151 |
--source include/assert.inc |
| 152 |
|
| 153 |
--echo |
| 154 |
--echo ############################################################ |
| 155 |
--echo # 8. Add more data to server 1 before server2 rejoins |
| 156 |
|
| 157 |
--let $rpl_connection_name = server1 |
| 158 |
--source include/rpl_connection.inc |
| 159 |
|
| 160 |
INSERT INTO t1 VALUES (3); |
| 161 |
INSERT INTO t1 VALUES (4); |
| 162 |
|
| 163 |
--source include/rpl_sync.inc |
| 164 |
|
| 165 |
--echo |
| 166 |
--echo ############################################################ |
| 167 |
--echo # 9. Unblock the rejoin, another clone should happen |
| 168 |
|
| 169 |
--let $rpl_connection_name = server2 |
| 170 |
--source include/rpl_connection.inc |
| 171 |
|
| 172 |
SET GLOBAL group_replication_clone_threshold= 1; |
| 173 |
|
| 174 |
SET DEBUG_SYNC = "now SIGNAL signal.autorejoin_continue"; |
| 175 |
|
| 176 |
--source include/wait_until_disconnected.inc |
| 177 |
|
| 178 |
--let $rpl_server_number= 2 |
| 179 |
--source include/rpl_reconnect.inc |
| 180 |
|
| 181 |
--let $group_replication_member_state=ONLINE |
| 182 |
--source include/gr_wait_for_member_state.inc |
| 183 |
|
| 184 |
--let $assert_text= Clone must be completed |
| 185 |
--let $assert_cond= [SELECT state="Completed" FROM performance_schema.clone_status] = 1; |
| 186 |
--source include/assert.inc |
| 187 |
|
| 188 |
# See if the data has been properly cloned in server2 |
| 189 |
--let $diff_tables=server1:test.t1, server2:test.t1, server3:test.t1 |
| 190 |
--source include/diff_tables.inc |
| 191 |
|
| 192 |
--echo |
| 193 |
--echo ############################################################ |
| 194 |
--echo # 10. Cleanup |
| 195 |
|
| 196 |
--let $rpl_connection_name= server1 |
| 197 |
--source include/rpl_connection.inc |
| 198 |
|
| 199 |
DROP TABLE t1; |
| 200 |
|
| 201 |
UNINSTALL PLUGIN clone; |
| 202 |
|
| 203 |
--let $rpl_connection_name= server3 |
| 204 |
--source include/rpl_connection.inc |
| 205 |
|
| 206 |
UNINSTALL PLUGIN clone; |
| 207 |
|
| 208 |
--let $rpl_connection_name= server2 |
| 209 |
--source include/rpl_connection.inc |
| 210 |
|
| 211 |
RESET PERSIST IF EXISTS group_replication_group_name; |
| 212 |
RESET PERSIST IF EXISTS group_replication_local_address; |
| 213 |
RESET PERSIST IF EXISTS group_replication_group_seeds; |
| 214 |
RESET PERSIST IF EXISTS group_replication_start_on_boot; |
| 215 |
RESET PERSIST IF EXISTS local_infile; |
| 216 |
RESET PERSIST IF EXISTS group_replication_communication_stack; |
| 217 |
|
| 218 |
UNINSTALL PLUGIN clone; |
| 219 |
|
| 220 |
--eval SET GLOBAL group_replication_clone_threshold= $_group_replication_threshold_save |
| 221 |
|
| 222 |
set session sql_log_bin=0; |
| 223 |
call mtr.add_suppression("This member will start distributed recovery using clone. It is due to the number of missing transactions being higher than the configured threshold of*"); |
| 224 |
call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR."); |
| 225 |
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected."); |
| 226 |
call mtr.add_suppression("Started auto-rejoin procedure attempt*"); |
| 227 |
call mtr.add_suppression("Auto-rejoin procedure attempt 1 of 1"); |
| 228 |
call mtr.add_suppression("Clone removing all user data for provisioning: Started"); |
| 229 |
call mtr.add_suppression("Clone removing all user data for provisioning: Finished"); |
| 230 |
set session sql_log_bin=1; |
| 231 |
|
| 232 |
--source include/clean_monitoring_process.inc |
| 233 |
|
| 234 |
--source include/group_replication_end.inc |