| 1 |
################################################################################ |
| 2 |
# This test verifies whether the group_replication works fine if the |
| 3 |
# donor server is killed when the joiner is already on recovery phase-2. |
| 4 |
# |
| 5 |
# Test: |
| 6 |
# 0. The test requires three servers: M1,M2 and M3. |
| 7 |
# 1. Start GR on servers M1 and M2. |
| 8 |
# 2. Execute some operations on the group through server M1 |
| 9 |
# using procedure dml_operations. |
| 10 |
# 3. Join M3 to the group and wait until the server is in Recovery. |
| 11 |
# 4. Identify the donor server for M3. |
| 12 |
# 5. perform the transactions on the group. |
| 13 |
# 6. Wait until recovery phase-1 on M3 ends. |
| 14 |
# 7. Kill and restart the donor server during phase-2 of M3 recovery. |
| 15 |
# 8.Wait until all the members are online. |
| 16 |
# 9.Verify that all the members have same data. |
| 17 |
# 10.Cleanup |
| 18 |
################################################################################ |
| 19 |
|
| 20 |
# This test does crashes servers, thence we skip it on valgrind. |
| 21 |
--source include/not_valgrind.inc |
| 22 |
--source include/big_test.inc |
| 23 |
--source include/force_restart.inc |
| 24 |
|
| 25 |
--source include/set_privilege_checks_user_as_system_user.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 |
# START GR on Two servers M1 and M2 |
| 32 |
--let $rpl_connection_name= server1 |
| 33 |
--source include/rpl_connection.inc |
| 34 |
|
| 35 |
SET sql_log_bin=0; |
| 36 |
CREATE TABLE t1(a int primary key); |
| 37 |
SET sql_log_bin=1; |
| 38 |
|
| 39 |
# Extract the server_uuid |
| 40 |
--let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 41 |
|
| 42 |
--source include/start_and_bootstrap_group_replication.inc |
| 43 |
|
| 44 |
--let $rpl_connection_name= server2 |
| 45 |
--source include/rpl_connection.inc |
| 46 |
|
| 47 |
SET sql_log_bin=0; |
| 48 |
CREATE TABLE t1(a int primary key); |
| 49 |
SET sql_log_bin=1; |
| 50 |
|
| 51 |
# Extract the server_uuid |
| 52 |
--let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) |
| 53 |
|
| 54 |
--source include/start_group_replication.inc |
| 55 |
|
| 56 |
# Perform the transactions on group through server1 so |
| 57 |
# that when M3 joins it will be in recovery for some time. |
| 58 |
|
| 59 |
--let $rpl_connection_name= server1 |
| 60 |
--source include/rpl_connection.inc |
| 61 |
|
| 62 |
# Create the procedure to perform dml operations |
| 63 |
delimiter $$; |
| 64 |
CREATE PROCEDURE dml_operations() |
| 65 |
BEGIN |
| 66 |
declare x INT; |
| 67 |
set x=1; |
| 68 |
while x<100 do |
| 69 |
insert into t1 values (x); |
| 70 |
update t1 set a=x+200 where a=x; |
| 71 |
delete from t1 where a<250; |
| 72 |
set x=x+1; |
| 73 |
end while; |
| 74 |
end$$ |
| 75 |
delimiter ;$$ |
| 76 |
--echo |
| 77 |
|
| 78 |
--echo ----call procedure---- |
| 79 |
call dml_operations(); |
| 80 |
--echo |
| 81 |
|
| 82 |
# Wait for the data to get synced on server2 |
| 83 |
--source include/rpl_sync.inc |
| 84 |
|
| 85 |
# JOIN M3 to the group |
| 86 |
--let $rpl_connection_name= server3 |
| 87 |
--source include/rpl_connection.inc |
| 88 |
|
| 89 |
SET sql_log_bin=0; |
| 90 |
CREATE TABLE t1(a int primary key); |
| 91 |
SET sql_log_bin=1; |
| 92 |
LOCK TABLES t1 READ; |
| 93 |
|
| 94 |
--let $rpl_connection_name= server_3 |
| 95 |
--source include/rpl_connection.inc |
| 96 |
|
| 97 |
SET SESSION sql_log_bin= 0; |
| 98 |
call mtr.add_suppression("There was an error when connecting to the donor server.*"); |
| 99 |
call mtr.add_suppression("For details please check performance_schema.replication_connection_status table and error log messages of Replica I/O for channel group_replication_recovery."); |
| 100 |
call mtr.add_suppression("Replica I/O for channel 'group_replication_recovery': Source command COM_REGISTER_REPLICA failed: failed registering on source, reconnecting to try again.*"); |
| 101 |
SET SESSION sql_log_bin= 1; |
| 102 |
|
| 103 |
--let $group_replication_start_member_state= RECOVERING |
| 104 |
--source include/start_group_replication.inc |
| 105 |
|
| 106 |
# Identify the donor_server for M3 |
| 107 |
|
| 108 |
--let $wait_timeout= 100 |
| 109 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='group_replication_recovery' AND service_state='ON' |
| 110 |
--source include/wait_condition.inc |
| 111 |
|
| 112 |
let $donor_id= 1; |
| 113 |
let $other_id= 2; |
| 114 |
|
| 115 |
if(`SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='group_replication_recovery' AND service_state='ON' AND source_uuid='$server2_uuid'`) |
| 116 |
{ |
| 117 |
let $donor_id= 2; |
| 118 |
let $other_id= 1; |
| 119 |
} |
| 120 |
|
| 121 |
# Connect to server which is neither M3 nor the donor server and |
| 122 |
# Create procedure to perform dml operations and call it using send. |
| 123 |
# So that these operations gets executed while server M3 is in recovery. |
| 124 |
|
| 125 |
--let $rpl_connection_silent= 1 |
| 126 |
--let $rpl_connection_name= server$other_id |
| 127 |
--source include/rpl_connection.inc |
| 128 |
# Create the procedure to perform dml operations |
| 129 |
delimiter $$; |
| 130 |
CREATE PROCEDURE dml_operations_2() |
| 131 |
BEGIN |
| 132 |
declare x INT; |
| 133 |
set x=100; |
| 134 |
while x<200 do |
| 135 |
insert into t1 values (x); |
| 136 |
update t1 set a=x+200 where a=x; |
| 137 |
delete from t1 where a<320; |
| 138 |
set x=x+1; |
| 139 |
end while; |
| 140 |
end$$ |
| 141 |
delimiter ;$$ |
| 142 |
--echo |
| 143 |
|
| 144 |
--echo ----call procedure---- |
| 145 |
send call dml_operations_2(); |
| 146 |
--echo |
| 147 |
|
| 148 |
# Wait until Recovery phase1 ends.(until the service_state of group_replication_recovery goes to OFF state.) |
| 149 |
--let $rpl_connection_name= server3 |
| 150 |
--source include/rpl_connection.inc |
| 151 |
UNLOCK TABLES; |
| 152 |
--let $wait_timeout=200 |
| 153 |
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='group_replication_recovery' AND service_state='OFF'; |
| 154 |
--source include/wait_condition.inc |
| 155 |
|
| 156 |
# Kill the donor server during phase 2 of M3's recovery |
| 157 |
--let $rpl_connection_name= server$donor_id |
| 158 |
--source include/rpl_connection.inc |
| 159 |
|
| 160 |
SET sql_log_bin=0; |
| 161 |
call mtr.add_suppression(".*Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state*"); |
| 162 |
SET sql_log_bin=1; |
| 163 |
|
| 164 |
# kill donor server |
| 165 |
--echo # killing |
| 166 |
--let $group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address` |
| 167 |
--let $group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds` |
| 168 |
--let $restart_parameters=restart:--group_replication_local_address=$group_replication_local_address --group_replication_group_seeds=$group_replication_group_seeds --group_replication_group_name=$group_replication_group_name |
| 169 |
--replace_result $group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME |
| 170 |
--source include/kill_and_restart_mysqld.inc |
| 171 |
--echo # restarting |
| 172 |
|
| 173 |
# Needed as we are not using rpl_restart_server.inc |
| 174 |
--let $rpl_server_number= $donor_id |
| 175 |
--source include/rpl_reconnect.inc |
| 176 |
|
| 177 |
--let $rpl_connection_name= server$other_id |
| 178 |
--source include/rpl_connection.inc |
| 179 |
reap; |
| 180 |
# Wait until group has only 2 members, that is, donor server's death is detected by |
| 181 |
# the group. |
| 182 |
--echo # check that there are 2 mebers in the group |
| 183 |
--let $group_replication_number_of_members= 2 |
| 184 |
--source include/gr_wait_for_number_of_members.inc |
| 185 |
|
| 186 |
--sleep 5 |
| 187 |
|
| 188 |
# Start GR on killed and restarted donor server and wait until all the servers are ONLINE. |
| 189 |
# Start GR on donor server |
| 190 |
--let $rpl_connection_name= server$donor_id |
| 191 |
--source include/rpl_connection.inc |
| 192 |
|
| 193 |
--let $wait_timeout= 200 |
| 194 |
--source include/start_group_replication.inc |
| 195 |
|
| 196 |
--let $rpl_connection_name= server$other_id |
| 197 |
--source include/rpl_connection.inc |
| 198 |
|
| 199 |
--let $wait_timeout= 200 |
| 200 |
--let $wait_condition= SELECT COUNT(*) = 3 FROM performance_schema.replication_group_members where MEMBER_STATE='ONLINE'; |
| 201 |
--source include/wait_condition.inc |
| 202 |
|
| 203 |
--source include/rpl_sync.inc |
| 204 |
|
| 205 |
# Verify that table t1 has same data on all the servers. |
| 206 |
--let $diff_tables=server1:t1, server2:t1, server3:t1 |
| 207 |
--source include/diff_tables.inc |
| 208 |
|
| 209 |
# Clean up. |
| 210 |
drop table t1; |
| 211 |
drop procedure dml_operations; |
| 212 |
drop procedure dml_operations_2; |
| 213 |
--let $skip_restore_connection= 0 |
| 214 |
--source include/group_replication_end.inc |