Debian Codegraph @

mysql-test/suite/group_replication/t/gr_recovery_channel.test

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