File: rpl_semi_sync_wait_slave_count.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (405 lines) | stat: -rw-r--r-- 15,081 bytes parent folder | download
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
################################################################################
# WL#7169 Semisync: make master wait for more than one slave to ack back
#
# The worklog added semisync master variable
# rpl_semi_sync_source_wait_for_replica_count. The variable controls how many acks
# from different slaves the transaction should wait for.
#
# The test verifies rpl_semi_sync_source_wait_for_replica_count works well.
################################################################################
--source include/not_group_replication_plugin.inc
--source include/have_debug.inc

--let rpl_topology=1->2, 1->3, 1->4, 1->5
--source include/rpl_init.inc
CREATE TABLE t1(c1 INT);
--source include/rpl_sync.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/install_semisync_source.inc

# It is for coverage test to cover the debug code.
SET GLOBAL rpl_semi_sync_source_trace_level= 255;

--echo ####################################################################
--echo # Test Case: Wait ack from 1 slave, but no semisync slave is enabled
--echo ####################################################################
--source include/save_semisync_yesno_tx.inc

# The statement will timeout, just make a smaller wait time.
SET GLOBAL rpl_semi_sync_source_timeout=3000;
INSERT INTO t1 VALUES(1);

--let $semi_sync_no_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--echo ###################################################################
--echo # Test Case: Wait ack from 1 slave, and 1 semisync slave is enabled
--echo ###################################################################
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/wait_for_semisync_source_status_on.inc
--source include/save_semisync_yesno_tx.inc

SET GLOBAL rpl_semi_sync_source_timeout=100000;
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

--echo #########################################################################
--echo # Test Case: Wait ack from 2 slaves, but only 1 semisync slave is enabled
--echo #########################################################################
--source include/save_semisync_yesno_tx.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2;
SET GLOBAL rpl_semi_sync_source_timeout=3000;

INSERT INTO t1 VALUES(10);

--let $semi_sync_no_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--echo #####################################################################
--echo # Test Case: Wait ack from 2 slaves, and 2 semisync slave are enabled
--echo #####################################################################
--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/wait_for_semisync_source_status_on.inc
--source include/save_semisync_yesno_tx.inc

SET GLOBAL rpl_semi_sync_source_timeout = 100000;
INSERT INTO t1 VALUES(102);
INSERT INTO t1 VALUES(103);

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

--echo ##########################################################################
--echo # Test Case: Wait ack from 3 slaves, but only 2 semisync slave are enabled
--echo ##########################################################################
--source include/save_semisync_yesno_tx.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 3;
SET GLOBAL rpl_semi_sync_source_timeout = 3000;
INSERT INTO t1 VALUES(100);
INSERT INTO t1 VALUES(101);

--let $semi_sync_no_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

--echo ######################################################################
--echo # Test Case: Wait ack from 3 slaves, and 3 semisync slaves are enabled
--echo ######################################################################
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--source include/install_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/wait_for_semisync_source_status_on.inc
--source include/save_semisync_yesno_tx.inc

SET GLOBAL rpl_semi_sync_source_timeout = 100000;
INSERT INTO t1 VALUES(102);
INSERT INTO t1 VALUES(103);

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

--echo ######################################################################
--echo # Test Case: Verify only the transaction before replied ack position
--echo #            can stop waiting and go ahead.
--echo ######################################################################
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
SET @original_debug = @@GLOBAL.debug;
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack';

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--source include/save_semisync_yesno_tx.inc

--send INSERT INTO t1 VALUES(104)

# Wait until above INSERT is replicated. It guarantees INSERT (104) is executed
# before INSERT(105)
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 104
--source include/wait_condition.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--send INSERT INTO t1 VALUES(105)

# Wait until 105 is applied on both server_2 and server_3. It guarantees that
# master has received acks from both server_2 and server_3.
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 105
--source include/wait_condition.inc

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--let $wait_condition= SELECT COUNT(*) FROM t1 WHERE c1 = 105
--source include/wait_condition.inc

# Let server_4 send the first ack for INSERT (104)
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
SET DEBUG_SYNC = 'now SIGNAL continue';

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--reap
--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc
--source include/save_semisync_yesno_tx.inc

# Let server_4 send the first ack for INSERT (105)
--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
SET DEBUG_SYNC = 'now SIGNAL continue';

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--reap
--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--echo ######################################################################
--echo # Test Case: Coverage test, it covers the branch that coming ack is
--echo #            greater than the acked already received.
--echo ######################################################################
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/save_semisync_yesno_tx.inc
--send INSERT INTO t1 VALUES(130);

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc

# The wait guarantees that it already sends the ack to master
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 130;
--source include/wait_condition.inc
SET @original_debug = @@GLOBAL.debug;
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack';

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc

# The wait guarantees that it already sends the ack to master
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 130;
--source include/wait_condition.inc
SET @original_debug = @@GLOBAL.debug;
SET GLOBAL debug = '+d,rpl_semisync_before_send_ack';

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--send INSERT INTO t1 VALUES(131);

--let $rpl_connection_name= server_5
--source include/rpl_connection.inc

# The wait guarantees that it already sends the ack to master
--let $wait_condition= SELECT count(*) FROM t1 WHERE c1 = 131;
--source include/wait_condition.inc
--source include/install_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--reap
--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc
--source include/save_semisync_yesno_tx.inc

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
SET GLOBAL debug = @original_debug;
SET DEBUG_SYNC= 'now SIGNAL continue';

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
SET GLOBAL debug = @original_debug;
SET DEBUG_SYNC= 'now SIGNAL continue';

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
SET GLOBAL debug = @original_debug;
SET DEBUG_SYNC= 'now SIGNAL continue';

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--reap
--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--echo ######################################################################
--echo # Test Case: Verify it can work well when number of semisync slaves
--echo # is greater than rpl_semi_sync_source_wait_for_replica_count
--echo ######################################################################
--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2;

--source include/save_semisync_yesno_tx.inc
INSERT INTO t1 VALUES(106);
INSERT INTO t1 VALUES(107);
# It guarantees semisync master get acks from all slaves.
--source include/rpl_sync.inc

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4;
--source include/save_semisync_yesno_tx.inc
INSERT INTO t1 VALUES(108);
INSERT INTO t1 VALUES(109);
--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

--echo ######################################################################
--echo # Test Case: It should still keep the old value and works well when
--echo # setting rpl_semi_sync_source_wait_for_replica_count fails
--echo ######################################################################
SET @original_debug = @@GLOBAL.debug;
SET GLOBAL debug = '+d,rpl_semisync_simulate_allocate_ack_container_failure';

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2;
--let $assert_variable_name= rpl_semi_sync_source_wait_for_replica_count
--let $assert_variable_value= 4
--source include/assert_variable.inc

--source include/save_semisync_yesno_tx.inc
INSERT INTO t1 VALUES(110);
INSERT INTO t1 VALUES(111);

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 5;
--let $assert_variable_name= rpl_semi_sync_source_wait_for_replica_count
--let $assert_variable_value= 4
--source include/assert_variable.inc

--source include/save_semisync_yesno_tx.inc
INSERT INTO t1 VALUES(112);
INSERT INTO t1 VALUES(113);

--let $semi_sync_yes_tx_increment= 2
--source include/assert_semisync_yesno_tx_increment.inc

SET GLOBAL debug = @original_debug;

--echo ########################################################################
--echo # Test Case: Verify it works well when some semisync slaves shutdown and
--echo #            rpl_semi_sync_source_wait_for_replica_count is decreased.
--echo ########################################################################
# This test requires semisync master is till on, even if it doesn't
# have enough slaves
SET GLOBAL rpl_semi_sync_source_wait_no_replica = 1;

# Transactions sould wait a long time, so they can succeed after
# rpl_semi_sync_source_wait_no_replica is decreased.
SET GLOBAL rpl_semi_sync_source_timeout = 90000000;

--let $rpl_connection_name= server_5
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--let $rpl_connection_name= server_4
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--let $rpl_connection_name= default
--source include/rpl_connection.inc

--source include/save_semisync_yesno_tx.inc
--send INSERT INTO t1 VALUES(201)

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
# It makes sure that master has received two acks
--source include/rpl_sync.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 2;

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--reap

--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--let $rpl_connection_name= server_3
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--source include/save_semisync_yesno_tx.inc

--send INSERT INTO t1 VALUES(202)

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
# It makes sure that master has received one ack
--source include/rpl_sync.inc

SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 1;

--let $rpl_connection_name= default
--source include/rpl_connection.inc
--reap

--let $semi_sync_yes_tx_increment= 1
--source include/assert_semisync_yesno_tx_increment.inc

--echo ########################################################################
--echo # Test Case: Verify semisync master will turn off immediately after a
--echo #            a semisync slave unregistered and there are no enough
--echo #            semisync slaves
--echo ########################################################################
SET GLOBAL rpl_semi_sync_source_wait_no_replica = 0;

--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/uninstall_semisync_replica.inc

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
--source include/wait_for_semisync_source_status_off.inc

--echo ########################################################################
--echo # Coverage Test
--echo ########################################################################
# Nothing is changed if the new value equals to the original value
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4;
SET GLOBAL rpl_semi_sync_source_wait_for_replica_count = 4;

# Ack array should be cleaned when disabling semisync master
SET GLOBAL rpl_semi_sync_source_enabled= OFF;
SET GLOBAL rpl_semi_sync_source_enabled= OFF;
SET GLOBAL rpl_semi_sync_source_enabled= ON;

# Ack array should be freed when uninstalling semisync master
--source include/uninstall_semisync_source.inc
# end

--let $rpl_connection_name= server_1
--source include/rpl_connection.inc
DROP TABLE t1;
CALL mtr.add_suppression(".* Timeout waiting for reply of binlog .*");
CALL mtr.add_suppression(".* Failed to allocate memory for ack_array .*");
--source include/rpl_end.inc