| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test will generate a random workload on the server mixing SBR and RBR |
| 4 |
# on same transaction using SAVEPOINT and ROLLBACK TO SAVEPOINT statements to |
| 5 |
# truncate the binlog cache in a certain point of the transaction and will |
| 6 |
# assert that all generated transactions have the correct transaction |
| 7 |
# "rbr_only" flag on GTID events. |
| 8 |
# |
| 9 |
# ==== Related Bugs and Worklogs ==== |
| 10 |
# |
| 11 |
# BUG#25040331: INTERLEAVED XA TRANSACTIONS MAY DEADLOCK SLAVE APPLIER WITH |
| 12 |
# REPEATABLE READ |
| 13 |
# |
| 14 |
--source include/have_binlog_format_mixed.inc |
| 15 |
RESET MASTER; |
| 16 |
|
| 17 |
--let $transactions=200 |
| 18 |
# First transaction is a DDL, so rbr_only will be "no" |
| 19 |
CREATE TABLE t1 (c1 INT AUTO_INCREMENT PRIMARY KEY, c2 TEXT, c3 INT DEFAULT 0); |
| 20 |
--let $rbr_only_flags= no |
| 21 |
|
| 22 |
--echo Generating $transactions transactions using SAVEPOINT/ROLLBACK TO SAVEPOINT |
| 23 |
--disable_query_log |
| 24 |
while ($transactions) |
| 25 |
{ |
| 26 |
--let $rbr_only= yes |
| 27 |
--let $inserts_before_savepoint=`SELECT FLOOR(1 + RAND() * 9)` |
| 28 |
--let $inserts_after_savepoint=`SELECT FLOOR(1 + RAND() * 9)` |
| 29 |
--let $inserts_after_rollback=`SELECT FLOOR(1 + RAND() * 9)` |
| 30 |
|
| 31 |
BEGIN; |
| 32 |
|
| 33 |
while ($inserts_before_savepoint) |
| 34 |
{ |
| 35 |
--let $insert_rbr=`SELECT FLOOR(1 + RAND() * 9) > 2` |
| 36 |
--let $inserts_before_savepoint=`SELECT FLOOR(1 + RAND() * 9)` |
| 37 |
--let $string_size=`SELECT FLOOR(1 + RAND() * 65534)` |
| 38 |
if ($insert_rbr) |
| 39 |
{ |
| 40 |
--eval INSERT INTO t1 (c2, c3) VALUES (REPEAT("X", $string_size), RAND()*100) |
| 41 |
} |
| 42 |
if (!$insert_rbr) |
| 43 |
{ |
| 44 |
--eval INSERT INTO t1 (c2) VALUES (REPEAT("X", $string_size)) |
| 45 |
--let $rbr_only= no |
| 46 |
} |
| 47 |
--dec $inserts_before_savepoint |
| 48 |
} |
| 49 |
|
| 50 |
SAVEPOINT `a`; |
| 51 |
|
| 52 |
while ($inserts_after_savepoint) |
| 53 |
{ |
| 54 |
--let $insert_rbr=`SELECT FLOOR(1 + RAND() * 9) > 2` |
| 55 |
--let $string_size=`SELECT FLOOR(1 + RAND() * 65534)` |
| 56 |
if ($insert_rbr) |
| 57 |
{ |
| 58 |
--eval INSERT INTO t1 (c2, c3) VALUES (REPEAT("X", $string_size), RAND()*100) |
| 59 |
} |
| 60 |
if (!$insert_rbr) |
| 61 |
{ |
| 62 |
--eval INSERT INTO t1 (c2) VALUES (REPEAT("X", $string_size)) |
| 63 |
} |
| 64 |
--dec $inserts_after_savepoint |
| 65 |
} |
| 66 |
|
| 67 |
ROLLBACK TO SAVEPOINT `a`; |
| 68 |
|
| 69 |
while ($inserts_after_rollback) |
| 70 |
{ |
| 71 |
--let $insert_rbr=`SELECT FLOOR(1 + RAND() * 9) > 2` |
| 72 |
--let $string_size=`SELECT FLOOR(1 + RAND() * 65534)` |
| 73 |
if ($insert_rbr) |
| 74 |
{ |
| 75 |
--eval INSERT INTO t1 (c2, c3) VALUES (REPEAT("X", $string_size), RAND()*100) |
| 76 |
} |
| 77 |
if (!$insert_rbr) |
| 78 |
{ |
| 79 |
--eval INSERT INTO t1 (c2) VALUES (REPEAT("X", $string_size)) |
| 80 |
--let $rbr_only= no |
| 81 |
} |
| 82 |
--dec $inserts_after_rollback |
| 83 |
} |
| 84 |
|
| 85 |
COMMIT; |
| 86 |
|
| 87 |
--let $rbr_only_flags= $rbr_only_flags,$rbr_only |
| 88 |
--dec $transactions |
| 89 |
} |
| 90 |
|
| 91 |
# Assert the "rbr_only" flags on binlog file |
| 92 |
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 93 |
# The workload is not deterministic, so skipping to print the expected flags |
| 94 |
--let $dont_print_rbr_only_flags= 1 |
| 95 |
--source include/assert_rbr_only_flags.inc |
| 96 |
|
| 97 |
# Cleanup |
| 98 |
DROP TABLE t1; |