File: gr_transaction_limit.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 (515 lines) | stat: -rw-r--r-- 18,851 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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
################################################################################
# The aim of the testcase is to test parameter
# 'group_replication_transaction_size_limit'
#
# 'group_replication_transaction_size_limit' should
# 1. limit size of transaction, roll-back larger transactions
# 2. Should not rollback/impact DDLs
# 3. If group_replication_transaction_size_limit is set to 0 it will be
#    turned off
# 4. Transaction size limit of each server
#    4.1 Server 1 should allow transactions of all size
#    4.2 Server 2 should not allow any transaction(DML)
#    4.3 Server 3 should allow transactions of size less than equal to 1024(DML)
#
# Test:
# 0. Start 3 servers with GR
#    0.1 For server 1 'group_replication_transaction_size_limit=0'
#    0.2 For server 2 'group_replication_transaction_size_limit=1'
#    0.3 For server 3 'group_replication_transaction_size_limit=1024'
# 1. Connect to server 1, create a table (t1)
#    Table t1 will be used later in step 3
# 2. Check DDLs
#    2.1 Create table t2 on server 1 and t3 on server 2.
#    2.2 Validate tables t2 and t3 are created on each server.
#    2.3 Drop table t2 on server 1 and table t3 on server 2.
#    2.4 Validate tables t2 and t3 are dropped on each server.
# 3. Check DMLs
#    3.1 Insert some data in table t1 on server 2,
#        transaction should be rolledback
#    3.2 Insert some data in table t1 on server 1, data should be inserted
#    3.3 Insert some data in table t1 on server 3, data should be inserted
#    3.4 Insert large sample data in table t1 on server 3,
#        transaction should be rolledback
#    3.5 Insert large sample data in table t1 on server 1,
#        data should be inserted
#    3.6 Delete all data from table t1 on server 2,
#        transaction should be rolledback
#    3.7 Delete all data from table t1 on server 3,
#        transaction should be rolledback
#    3.8 Delete all data from table t1 on server 1, table will be empty
# 4. Validate that server1, server2 and server 3 has same set of data
# 5. Clean-up
################################################################################
--echo
--echo ## 0. Start 3 servers with GR
--source include/big_test.inc
--source include/have_group_replication_plugin.inc
--let $rpl_server_count= 3
--source include/group_replication.inc

# Configure group replication on three servers

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
set session sql_log_bin=0;
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
call mtr.add_suppression("Error on session .*. Transaction of size .* exceeds specified limit 9. To increase the limit please adjust group_replication_transaction_size_limit option.");
call mtr.add_suppression("Error on session .*. Transaction of size .* exceeds specified limit 808. To increase the limit please adjust group_replication_transaction_size_limit option.");
set session sql_log_bin=1;

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
set session sql_log_bin=0;
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
call mtr.add_suppression("Error on session .*. Transaction of size .* exceeds specified limit 1024. To increase the limit please adjust group_replication_transaction_size_limit option.");
set session sql_log_bin=1;

# Make sure number of servers in the group is 3
--echo
--let $group_replication_number_of_members= 3
--source include/gr_wait_for_number_of_members.inc

################################################################################
--echo
--echo ## 1. Connect to server 1, create a table (t1)
--echo ##    Table t1 will be used later in step 3
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
CREATE TABLE t1 (a INT PRIMARY KEY);

--source include/rpl_sync.inc
################################################################################
--echo
--echo ## 2.1 Create table t2 on server 1 and t3 on server 2.

--let $rpl_connection_name= server1
--source include/rpl_connection.inc
CREATE TABLE t2 (a INT PRIMARY KEY);
--source include/rpl_sync.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
CREATE TABLE t3 (a INT PRIMARY KEY);
--source include/rpl_sync.inc
################################################################################
--echo
--echo ## 2.2 Validate tables t2 and t3 are created on each server.

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

--let $assert_text= 'Check table t2 exist on server 1'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 1
--source include/assert.inc

--let $assert_text= 'Check table t3 exist on server 1'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 1
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Check table t2 exist on server 2'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 1
--source include/assert.inc

--let $assert_text= 'Check table t3 exist on server 2'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 1
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Check table t2 exist on server 3'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 1
--source include/assert.inc

--let $assert_text= 'Check table t3 exist on server 3'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 1
--source include/assert.inc
################################################################################
--echo
--echo ## 2.3 Drop table t2 on server 1 and table t3 on server 2.

## Since DDLs are not blocked CREATE and DROP statements should be replicated
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
DROP TABLE t2;
--source include/rpl_sync.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
DROP TABLE t3;
--source include/rpl_sync.inc
################################################################################
--echo
--echo ## 2.4 Validate tables t2 and t3 are dropped on each server.

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

--let $assert_text= 'Check table t2 dropped on server 1'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 0
--source include/assert.inc

--let $assert_text= 'Check table t3 dropped on server 1'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Check table t2 dropped on server 2'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 0
--source include/assert.inc

--let $assert_text= 'Check table t3 dropped on server 2'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Check table t2 dropped on server 3'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t2\"]" = 0
--source include/assert.inc

--let $assert_text= 'Check table t3 dropped on server 3'
--let $assert_cond= "[SELECT COUNT(*) FROM information_schema.tables WHERE TABLE_SCHEMA=\"test\" AND TABLE_NAME=\"t3\"]" = 0
--source include/assert.inc

################################################################################
--echo
--echo ## 3.1 Insert some data in table t1 on server 2,
--echo ##     transaction should be rolledback

## Reason of rollback is Server 2 allows transaction of size <= 1 byte
## Its expected all DMLs will be of size greater then 1 and will be rolledback
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--error ER_RUN_HOOK_ERROR
--eval INSERT INTO t1 VALUES (10)
--source include/rpl_sync.inc

## Assert : Confirm table t1 has 0 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc
################################################################################
--echo
--echo ## 3.2 Insert some data in table t1 on server 1, data should be inserted

## In server 1 all transactions should work since tx size switch is OFF
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
INSERT INTO t1 VALUES (10);
--source include/rpl_sync.inc

## Assert : Confirm table t1 has 1 row on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 1
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 1
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 1
--source include/assert.inc
################################################################################
--echo
--echo ## 3.3 Insert some data in table t1 on server 3, data should be inserted

## In sever 3 transactions of size <= 1024 should work
--let $rpl_connection_name= server3
--source include/rpl_connection.inc
INSERT INTO t1 VALUES (20);
--source include/rpl_sync.inc

## In section 3.2, 1 records was inserted so total records now are 2
## Assert : Confirm table t1 has 2 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 2
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 2
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 2
--source include/assert.inc

# In next section  we will insert 100 records
# There are already 2 records inserted in 3.2 and 3.3
# To avoid confusion later we will clean this 2 records for next operations
--echo
DELETE FROM t1;
--source include/rpl_sync.inc
################################################################################
--echo
--echo ## 3.4 Insert large sample data in table t1 on server 3,
--echo ##     transaction should be rolledback

## We will insert 100 records, so size of transaction will go beyond 1024 limit
## of server 3
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

BEGIN;
--disable_query_log
--let $rows= 100
WHILE($rows)
{
  --eval INSERT INTO t1 (a) VALUES ( $rows )
  --dec $rows
}
--enable_query_log
--error ER_RUN_HOOK_ERROR
COMMIT;
--source include/rpl_sync.inc

## Since there is rollback, records should not be present
## Assert : Confirm table t1 has 0 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 0
--source include/assert.inc
################################################################################
--echo
--echo ## 3.5 Insert large sample data in table t1 on server 1,
--echo ##     data should be inserted

## We will insert 100 records, for server 1 switch is off
## so transaction should be committed successfully from server 1
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

BEGIN;
--disable_query_log
--let $rows=100
WHILE($rows)
{
  --eval INSERT INTO t1 (a) VALUES ( $rows )
  --dec $rows
}
--enable_query_log
COMMIT;
--source include/rpl_sync.inc

## Assert : Confirm table t1 has 100 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc
################################################################################
--echo
--echo ## 3.6 Delete all data from table t1 on server 2,
--echo ##     transaction should be rolledback

## Since 100 records will be deleted, transaction size is big and will be
## rolledback
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

# Make the transaction fail for total transaction size, not the write sets
SET @group_replication_transaction_size_limit_save= @@GLOBAL.group_replication_transaction_size_limit;
# 100 * 8 = 800 bytes for writesets
SET GLOBAL group_replication_transaction_size_limit= 808;

--error ER_RUN_HOOK_ERROR
--eval DELETE FROM t1
--source include/rpl_sync.inc

SET GLOBAL group_replication_transaction_size_limit= @group_replication_transaction_size_limit_save;

## Confirm rows are not deleted
## Assert : Confirm table t1 has 100 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc
################################################################################
--echo
--echo ## 3.7 Delete all data from table t1 on server 3,
--echo ##     transaction should be rolledback
## Since 100 records will be deleted, transaction size is big and will be
## rolledback

## Transaction size is sum of (Transaction changes + Transaction hash)
## This test is important because in below transaction:
## Transaction Change size is 667
## Transaction Hash size is 1614
## Limit of transaction size is 1024 for server 3
##
## Since 667+1614 > 1024 transaction should be rolledback
## If transaction succedds, wait_condition will fail because of different
## number of records before and after transaction indicating issues with code

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

--error ER_RUN_HOOK_ERROR
--eval DELETE FROM t1
--source include/rpl_sync.inc

# Confirm rows are not deleted
## Assert : Confirm table t1 has 100 rows on each server
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc

--echo
--let $rpl_connection_name= server3
--source include/rpl_connection.inc

--let $assert_text= 'Checking the number of records in table t1'
--let $assert_cond= [SELECT COUNT(*) as count FROM t1,count, 1] = 100
--source include/assert.inc
################################################################################
--echo
--echo ## 3.8 Delete all data from table t1 on server 1, table will be empty

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

DELETE FROM t1;
--source include/rpl_sync.inc
################################################################################
--echo
--echo ## 4. Validate that server1, server2 and server 3 has same set of data

--let $diff_tables= server1:test.t1, server2:test.t1, server3:test.t1
--source include/diff_tables.inc
################################################################################
--echo
--echo ## 5. Clean-up

DROP TABLE t1;

--source include/group_replication_end.inc
################################################################################