Debian Codegraph @

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

raw
1 ################################################################################
2 # This test verifies whether the group_replication works fine if the
3 # donor servers are killed one after the other while some server is in
4 # Recovery state.
5 #
6 # Test:
7 # 0. The test requires three servers: M1,M2 and M3.
8 # 1. Start GR on servers M1 and M2.
9 # 2. Execute some operations on the group through server M1
10 # using procedure dml_operations.
11 # 3. Join M3 to the group and wait until the server is in Recovery.
12 # 4. Identify the donor server for M3.
13 # 5. kill and restart the donor server.
14 # 6. Again Join the restarted member to the group.
15 # 7. Repeat the steps 4-6 for several times.
16 # 8. Wait until all the servers are online.
17 # 9. Verify that all the members have same data.
18 # 10.Cleanup
19 ################################################################################
20
21 # This test does crashes servers, thence we skip it on valgrind.
22 --source include/not_valgrind.inc
23 --source include/big_test.inc
24 --source include/force_restart.inc
25
26 --source include/set_privilege_checks_user_as_system_user.inc
27 --source include/have_group_replication_plugin.inc
28 --let $rpl_server_count= 3
29 --let $rpl_skip_group_replication_start= 1
30 --source include/group_replication.inc
31
32 # START GR on Two servers M1 and M2
33 --let $rpl_connection_name= server1
34 --source include/rpl_connection.inc
35
36 SET SESSION sql_log_bin=0;
37 --disable_query_log
38 call mtr.add_suppression("\\[Warning\\] \\[[^]]*\\] Database page corruption or a failed file read of page");
39 --enable_query_log
40 SET SESSION sql_log_bin=1;
41
42 # Extract the server_uuid
43 --let $server1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
44
45 SET sql_log_bin=0;
46 CREATE TABLE t1(a int primary key);
47 SET sql_log_bin=1;
48
49 --source include/start_and_bootstrap_group_replication.inc
50
51 --let $rpl_connection_name= server2
52 --source include/rpl_connection.inc
53
54 # Extract the server_uuid
55 --let $server2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
56
57 SET sql_log_bin=0;
58 CREATE TABLE t1(a int primary key);
59 SET sql_log_bin=1;
60
61 --source include/start_group_replication.inc
62
63 # Execute the operations on the group through server1 so
64 # that when server3 joins it will be in RECOVERY for some time.
65
66 --let $rpl_connection_name= server1
67 --source include/rpl_connection.inc
68
69 # Create the procedure to perform dml operations
70 delimiter $$;
71 CREATE PROCEDURE dml_operations()
72 BEGIN
73 declare x INT;
74 set x=1;
75 while x<600 do
76 insert into t1 values (x);
77 update t1 set a=x+600 where a=x;
78 delete from t1 where a<650;
79 set x=x+1;
80 end while;
81 end$$
82 delimiter ;$$
83 --echo
84
85 --echo ----call procedure----
86 call dml_operations();
87 --echo
88
89 # Wait for the data to get synced on server2.
90 --source include/rpl_sync.inc
91
92 # JOIN M3 to the group
93 --let $rpl_connection_name= server3
94 --source include/rpl_connection.inc
95
96 SET sql_log_bin=0;
97 CREATE TABLE t1(a int primary key);
98 SET sql_log_bin=1;
99 LOCK TABLES t1 READ;
100
101 --let $rpl_connection_name= server_3
102 --source include/rpl_connection.inc
103
104 SET SESSION sql_log_bin= 0;
105 call mtr.add_suppression("Plugin group_replication reported: 'There was an error when connecting to the donor server.*");
106 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.");
107 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.*");
108 SET SESSION sql_log_bin= 1;
109
110 --let $group_replication_start_member_state= RECOVERING
111 --source include/start_group_replication.inc
112
113 --let $count=1
114
115 --let $wait_timeout= 100
116 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_connection_status WHERE channel_name='group_replication_recovery' AND service_state='ON'
117 --source include/wait_condition.inc
118
119 while($count<6)
120 {
121 --let $rpl_connection_name= server_3
122 --source include/rpl_connection.inc
123 # Identify the donor_server for M3
124 let $donor_id= 1;
125 let $other_id= 2;
126
127 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'`)
128 {
129 let $donor_id= 2;
130 let $other_id= 1;
131 }
132
133 --let $rpl_connection_name= server3
134 --source include/rpl_connection.inc
135 UNLOCK TABLES;
136
137 --let $rpl_connection_silent= 1
138 --let $rpl_connection_name= server$donor_id
139 --source include/rpl_connection.inc
140
141 # kill the donor server
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 --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
145 --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
146 --source include/kill_and_restart_mysqld.inc
147
148 # Needed as we are not using rpl_restart_server.inc
149 --let $rpl_server_number= $donor_id
150 --source include/rpl_reconnect.inc
151
152 --let $rpl_connection_name= server3
153 --source include/rpl_connection.inc
154 LOCK TABLES t1 READ;
155
156 --let $rpl_connection_name= server$other_id
157 --source include/rpl_connection.inc
158
159 --let $wait_condition= SELECT COUNT(*) = 2 FROM performance_schema.replication_group_members
160 --source include/wait_condition.inc
161
162 # Sleep for some time so that some time elapse before the restarted server rejoins the group.
163 --sleep 5
164
165 --let $rpl_connection_name= server$donor_id
166 --source include/rpl_connection.inc
167 --let $wait_timeout= 100
168 --source include/start_group_replication.inc
169
170 --inc $count
171 --let $rpl_connection_silent= 0
172 }
173
174 --let $rpl_connection_name= server3
175 --source include/rpl_connection.inc
176 UNLOCK TABLES;
177
178 # Wait until all the servers are online
179 --let $wait_timeout=300
180 --let $wait_condition= SELECT COUNT(*) = 3 FROM performance_schema.replication_group_members where MEMBER_STATE='ONLINE';
181 --source include/wait_condition.inc
182 --source include/rpl_sync.inc
183
184 # Verify that table t1 has same data on all the servers.
185 --let $diff_tables=server1:t1, server2:t1, server3:t1
186 --source include/diff_tables.inc
187
188 # Clean up.
189 drop table t1;
190 drop procedure dml_operations;
191 --let $skip_restore_connection= 0
192 --source include/group_replication_end.inc