Debian Codegraph @

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

raw
1 ################################################################################
2 # Verify that when a member is blocked on a minority and waiting on a blocked
3 # query, group replication will kill all transactions after a while and leave
4 # the group enabling super read mode.
5 # Steps:
6 # 0) The test requires three servers: M1, M2 and M3.
7 # 1) Create a group with 3 members, we want fourth server for async channel.
8 # 2) Check the group_replication_unreachable_majority_timeout var boundaries
9 # 2.1) Check min value of group_replication_unreachable_majority_timeout
10 # 2.1) Check max value of group_replication_unreachable_majority_timeout
11 # 3) Create a minority situation with only 1 member alive: M1
12 # Assert M2 and M3 are unreachable
13 # 4) Execute a query on M1 that will block
14 # 5) Wait a minute and assert
15 # * member state is ERROR
16 # * super read only mode is ON
17 # * the query rolled back
18 # 6) Confirm on server1 Slave IO and SQL threads are not running.
19 # 7) Clean up.
20 ################################################################################
21 # Don't test this under valgrind, memory leaks will occur
22 --source include/not_valgrind.inc
23 --source include/big_test.inc
24 --source include/force_restart.inc
25 --source include/have_group_replication_plugin.inc
26
27 --echo #
28 --echo # 1. Create a group with 3 members,
29 --echo # we want fourth server for async channel.
30 --echo # Extract each server uuid
31 --echo # Create a table on it.
32 --echo #
33
34 --let $rpl_server_count= 4
35 --source include/group_replication.inc
36
37 --let $rpl_connection_name= server1
38 --source include/rpl_connection.inc
39 --let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
40 --let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address`
41
42 --let $rpl_connection_name= server2
43 --source include/rpl_connection.inc
44 --let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
45
46 --let $rpl_connection_name= server3
47 --source include/rpl_connection.inc
48 --let $member3_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
49
50 --let $rpl_connection_name= server4
51 --source include/rpl_connection.inc
52 --source include/stop_group_replication.inc
53
54 --let $rpl_connection_name= server1
55 --source include/rpl_connection.inc
56 --replace_result $SERVER_MYPORT_4 SERVER_4_PORT
57 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='127.0.0.1', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_4 for channel 'ch4_1'
58
59 --let $rpl_channel_name= 'ch4_1'
60 --source include/start_slave.inc
61 --let $rpl_channel_name=
62
63 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
64 --source include/rpl_sync.inc
65
66 --echo #
67 --echo # 2. Check group_replication_unreachable_majority_timeout boundaries
68 --echo #
69
70 --let $rpl_connection_name= server1
71 --source include/rpl_connection.inc
72
73 --let $saved_unr_timeout= `SELECT @@GLOBAL.group_replication_unreachable_majority_timeout`
74
75 --echo # 2.1. Set group_replication_unreachable_majority_timeout below min value
76 SET @@GLOBAL.group_replication_unreachable_majority_timeout= -1;
77
78 --echo # 2.1. Check min value of group_replication_unreachable_majority_timeout
79 --let $assert_text= Minimum group_replication_unreachable_majority_timeout is 0
80 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_unreachable_majority_timeout]" = 0
81 --source include/assert.inc
82
83 --echo # 2.2. Set group_replication_unreachable_majority_timeout above max value.
84 SET @@GLOBAL.group_replication_unreachable_majority_timeout= 31536001;
85
86 --echo # 2.2. Check max value of group_replication_unreachable_majority_timeout.
87 --let $assert_text= Maximum group_replication_unreachable_majority_timeout is 31536000
88 --let $assert_cond= "[SELECT @@GLOBAL.group_replication_unreachable_majority_timeout]" = 31536000
89
90 # Set a low value for the test
91 SET @@GLOBAL.group_replication_unreachable_majority_timeout= 11;
92
93 --echo #
94 --echo # 3. Crash server 2 and server 3
95 --echo # Check they are marked as unreachable
96 --echo #
97 # We do kill the servers, using shutdown_server 0, and then MTR will
98 # follow the expect file and restart the server, but we do not wait
99 # for the server restart.
100 # Since the servers loose its GCS configuration them will not rejoin
101 # the group.
102
103 --let $rpl_connection_name= server2
104 --source include/rpl_connection.inc
105 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
106 --shutdown_server 0
107 --source include/wait_until_disconnected.inc
108
109 --let $rpl_connection_name= server3
110 --source include/rpl_connection.inc
111 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
112 --shutdown_server 0
113 --source include/wait_until_disconnected.inc
114
115 --let $rpl_connection_name= server1
116 --source include/rpl_connection.inc
117
118 --let $group_replication_member_state= UNREACHABLE
119 --let $group_replication_member_id= $member2_uuid
120 --source include/gr_wait_for_member_state.inc
121
122 --let $group_replication_member_state= UNREACHABLE
123 --let $group_replication_member_id= $member3_uuid
124 --source include/gr_wait_for_member_state.inc
125
126 --let $group_replication_member_id= $member1_uuid
127
128 --echo #
129 --echo # 4. Execute a query that will block
130 --echo #
131
132 --send INSERT INTO t1 VALUES (2)
133
134 --echo #
135 --echo # 5. After some seconds the member should go into error mode.
136 --echo # It should enable super read only mode and kill pending transactions.
137 --echo #
138
139 --let $rpl_connection_name= server_1
140 --source include/rpl_connection.inc
141
142 # verify thread THD_group_partition_handler has started
143 --let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE NAME = "thread/group_rpl/THD_group_partition_handler"
144 --source include/wait_condition.inc
145
146 --let $group_replication_member_state= ERROR
147 --source include/gr_wait_for_member_state.inc
148
149 --let $rpl_connection_name= server1
150 --source include/rpl_connection.inc
151
152 --error ER_RUN_HOOK_ERROR
153 --reap
154
155 --echo # The server's read_only mode should be enabled
156 --let $assert_text= The super_read_only mode should be 1.
157 --let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 1;
158 --source include/assert.inc
159
160
161 --echo
162 --echo # 6. Confirm on server1 Slave IO and SQL threads are not running.
163
164 --let $slave_param= Slave_IO_Running
165 --let $slave_param_value= No
166 --source include/check_slave_param.inc
167
168 --let $slave_param= Slave_SQL_Running
169 --let $slave_param_value= No
170 --source include/check_slave_param.inc
171
172
173 --echo #
174 --echo # 7. Clean up.
175 --echo #
176
177 --source include/stop_group_replication.inc
178
179 --let $rpl_connection_name= server1
180 --source include/rpl_connection.inc
181
182 DROP TABLE t1;
183
184 --disable_query_log
185 --eval SET @@GLOBAL.group_replication_unreachable_majority_timeout= $saved_unr_timeout
186 --enable_query_log
187
188 set session sql_log_bin=0;
189 call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*");
190 call mtr.add_suppression("'This member could not reach a majority of the members for more than.*");
191 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
192 call mtr.add_suppression("Due to a plugin error, some transactions were unable to be certified and will now rollback.");
193 call mtr.add_suppression("Error while waiting for conflict detection procedure to finish on session.*");
194 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
195 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
196 call mtr.add_suppression("Timeout while waiting for the group communication engine to exit!");
197 call mtr.add_suppression("The member has failed to gracefully leave the group.");
198 call mtr.add_suppression("read failed");
199 set session sql_log_bin=1;
200
201 --let $rpl_connection_name= server_2
202 --source include/rpl_connection.inc
203
204 --let $rpl_server_number= 2
205 --source include/rpl_reconnect.inc
206
207 DROP TABLE t1;
208
209 --let $rpl_connection_name= server_3
210 --source include/rpl_connection.inc
211
212 --let $rpl_server_number= 3
213 --source include/rpl_reconnect.inc
214
215 DROP TABLE t1;
216
217 --source include/group_replication_end.inc