1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
################################################################################
# This test validates the behavior of the group replication recovery channel
# against common slave commands like START/STOP/RESET SLAVE.
#
# Test:
# 0. The test requires three servers: M1, M2 and M3.
# 1. Bootstrap start group replication on M2. Add some data for recovery.
# Start M1.
# 2. Stop replication on M1. On M2 lock a table to block recovery. Start M1.
# 3. Execute a STOP SLAVE command and see the recovery channel still active.
# 4. Execute a RESET SLAVE ALL command and see the recovery channel is not
# affected on M1 when GR node is active.
# 5. Kill the server M1. The recovery channel should still be there but it's
# not started. Recreate the slave channel to test that it started
# 6. Clean the created channels and tables.
################################################################################
# This test does crashes servers, thence we skip it on valgrind.
--source include/not_valgrind.inc
--source include/big_test.inc
--source include/force_restart.inc
--source include/have_group_replication_plugin.inc
--let $rpl_skip_group_replication_start= 1
--let $rpl_server_count= 3
--source include/group_replication.inc
#
# Phase 1: Start group replication on two servers
#
--connection server2
--echo server2
--source include/start_and_bootstrap_group_replication.inc
# Add some data for recovery
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--connection server1
--echo server1
--source include/start_group_replication.inc
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--connection server2
--let $group_replication_number_of_members= 2
--source include/gr_wait_for_number_of_members.inc
#
# Phase 2: Stop replication on server 1
# On server 2 lock a table to block recovery
#
--connection server1
--source include/stop_group_replication.inc
--connection server2
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
#lock the table in a different connection
--connection server_1
LOCK TABLE t1 READ;
--connection server1
--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc
#
# Phase 3: Execute a STOP SLAVE command and see the channel still active.
#
let $wait_condition=
SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status where CHANNEL_NAME="group_replication_recovery" and SERVICE_STATE="ON";
--source include/wait_condition.inc
STOP SLAVE;
--let $assert_text= 'The group replication recovery channel is ON'
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="group_replication_recovery" and SERVICE_STATE="ON", count, 1] = 1
--source include/assert.inc
#
# Phase 4: Execute a RESET SLAVE ALL command and see the recovery channel is
# not affected as GR node is active.
#
--connection server1
SET GLOBAL SUPER_READ_ONLY=0; # Bug#22097534
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_AUTO_POSITION=1 FOR CHANNEL "channel_1"
--let $assert_text= 'The slave channel is present'
--let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="channel_1", count, 1] = 1
--source include/assert.inc
--let $datadir_1= `SELECT @@GLOBAL.datadir`
--let $recovery_relay_log_file= `SELECT CONCAT('$datadir_1', 'mgr-group_replication_recovery.000001')`
--file_exists $recovery_relay_log_file
--let $recovery_relay_log_index= `SELECT CONCAT('$datadir_1', 'mgr-group_replication_recovery.index')`
--file_exists $recovery_relay_log_index
--error ER_REPLICA_CHANNEL_OPERATION_NOT_ALLOWED
RESET SLAVE ALL;
--let $assert_text= 'The group replication recovery channel is present'
--let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_recovery", count, 1] = 1
--source include/assert.inc
--let $assert_text= 'The group replication recovery channel is ON'
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="group_replication_recovery" and SERVICE_STATE="ON", count, 1] = 1
--source include/assert.inc
--file_exists $recovery_relay_log_file
--file_exists $recovery_relay_log_index
--let $assert_text= 'The slave channel is not present'
--let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="channel_1", count, 1] = 0
--source include/assert.inc
#
# Phase 5: Kill the server
# The recovery channel should still be there but it's not started
# Recreate the slave channel to test that it started
#
--connection server1
--replace_result $SERVER_MYPORT_3 SERVER_3_PORT
--eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1", SOURCE_USER="root", SOURCE_PASSWORD="", SOURCE_PORT=$SERVER_MYPORT_3, SOURCE_AUTO_POSITION=1 FOR CHANNEL "channel_1"
--source include/start_slave.inc
--let $assert_text= 'The created slave channel is ON'
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="channel_1" and SERVICE_STATE="ON", count, 1] = 1
--source include/assert.inc
--let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
# kill server 1
--let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds
--replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
--source include/kill_and_restart_mysqld.inc
#Needed as we are not using rpl_restart_server.inc
--let $rpl_server_number= 1
--source include/rpl_reconnect.inc
# Wait until group has only 1 member, that is, server1 death is detected by
# the group.
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $group_replication_member_state= UNREACHABLE
--let $group_replication_member_id= $member1_uuid
--source include/gr_wait_for_member_state.inc
# unblock the group, since server1 has gone away and
# there were only two in the group - majority lost
--let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address`
--disable_query_log
# Reseting the group to server2 only
--eval SET GLOBAL group_replication_force_members= "$local_address_server2"
--enable_query_log
--let $group_replication_number_of_members= 1
--source include/gr_wait_for_number_of_members.inc
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
# Wait for the slave channel start
--let $rpl_channel_name= 'channel_1'
--source include/wait_for_slave_to_start.inc
--let $rpl_channel_name=
--let $assert_text= 'The group replication recovery channel is present'
--let $assert_cond= [SELECT COUNT(*) AS count FROM mysql.slave_relay_log_info WHERE channel_name="group_replication_recovery", count, 1] = 1
--source include/assert.inc
--let $assert_text= 'The group replication recovery channel is OFF'
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="group_replication_recovery" and SERVICE_STATE="OFF", count, 1] = 1
--source include/assert.inc
--let $assert_text= 'The created slave channel is ON'
--let $assert_cond= [SELECT COUNT(*) AS count FROM performance_schema.replication_connection_status where CHANNEL_NAME="channel_1" and SERVICE_STATE="ON", count, 1] = 1
--source include/assert.inc
#
# Phase 6: Clean the created channels and tables
#
--connection server2
DROP TABLE t1;
--connection server1
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0 FOR CHANNEL "channel_1";
--source include/start_group_replication.inc
--let $skip_restore_connection= 0
--source include/group_replication_end.inc
|