| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that binlog compression does not break for transactions that |
| 4 |
# would exceed 1 GiB compressed. |
| 5 |
# |
| 6 |
# ==== Requirements ==== |
| 7 |
# |
| 8 |
# R1. If the compressed size of a transaction exceeds 1 GiB, |
| 9 |
# replication should fall back to uncompressed. |
| 10 |
# |
| 11 |
# ==== Implementation ==== |
| 12 |
# |
| 13 |
# - To add a little more than 64 MiB compressed data to a transaction, |
| 14 |
# generate a file with a little more than 64 MiB and insert the |
| 15 |
# contents into a table. Use 'dd' reading from '/dev/random', since |
| 16 |
# it is faster than any builtin random SQL functions. |
| 17 |
# - Repeat the above 16 times to produce a transaction that will be |
| 18 |
# slightly bigger than 1 GiB compressed, even if every event is only |
| 19 |
# a little more than 64 MiB. |
| 20 |
# |
| 21 |
# ==== References ==== |
| 22 |
# |
| 23 |
# BUG#33588473: Binlog compression breaks when compressed size exceeds 1 GiB |
| 24 |
|
| 25 |
--source include/big_test.inc |
| 26 |
# Needs dd and /dev/random |
| 27 |
--source include/linux.inc |
| 28 |
--source include/have_grep.inc |
| 29 |
--source include/have_binlog_format_row.inc |
| 30 |
|
| 31 |
let $sysvars_to_save = [ "GLOBAL.max_allowed_packet" ]; |
| 32 |
--source include/save_sysvars.inc |
| 33 |
|
| 34 |
# The session value is read-only. So we set the global value here, |
| 35 |
# before master-slave.inc creates the sessions. |
| 36 |
SET @@global.max_allowed_packet = 1024*1024*1024;#1073741824; |
| 37 |
|
| 38 |
--source include/master-slave.inc |
| 39 |
|
| 40 |
--echo |
| 41 |
--echo ==== Setup variables ==== |
| 42 |
|
| 43 |
# Generate $file_count files of random data, |
| 44 |
# each one by writing $block_count blocks of $block_size bytes. |
| 45 |
# The total size is $file_count*$block_size*$block_count>4 GiB. |
| 46 |
# (We add the term 1<<10 to $block_size to ensure it is a little bigger.) |
| 47 |
# The size of each file is $block_size*$block_count=512 MiB. |
| 48 |
# The division into block_size/block_count is chosen to make dd as |
| 49 |
# fast as possible. |
| 50 |
--let $file_count = `SELECT 1<<3` |
| 51 |
--let $block_size = `SELECT (1<<24) + (1<<10)` |
| 52 |
--let $block_count = `SELECT 1<<3` |
| 53 |
--expr $file_size = $block_size * $block_count |
| 54 |
--expr $total_size = $file_size * $file_count |
| 55 |
|
| 56 |
--let $datadir = `SELECT @@datadir` |
| 57 |
--let $file = $datadir/bigfile |
| 58 |
|
| 59 |
--let $c = 0 |
| 60 |
while ($c < 2) { |
| 61 |
--echo |
| 62 |
--echo ==== Scenario: compression=$c ==== |
| 63 |
|
| 64 |
--source include/rpl_connection_master.inc |
| 65 |
|
| 66 |
--echo * Writing $block_count * $block_size random bytes to file, $file_count times |
| 67 |
|
| 68 |
FLUSH BINARY LOGS; |
| 69 |
|
| 70 |
eval SET @@session.binlog_transaction_compression = $c; |
| 71 |
--source include/save_binlog_position.inc |
| 72 |
|
| 73 |
CREATE TABLE t1 (x LONGBLOB); |
| 74 |
|
| 75 |
BEGIN; |
| 76 |
--let $i = 1 |
| 77 |
while ($i <= $file_count) { |
| 78 |
--echo # Iteration $i/$file_count |
| 79 |
# Write random data to file. |
| 80 |
--exec dd if=/dev/urandom of=$file bs=$block_size count=$block_count 2> /dev/null |
| 81 |
# Read data into table. |
| 82 |
--replace_result $file FILE |
| 83 |
eval INSERT INTO t1 VALUES (LOAD_FILE('$file')); |
| 84 |
--inc $i |
| 85 |
} |
| 86 |
COMMIT; |
| 87 |
|
| 88 |
--echo |
| 89 |
--echo ==== Verify result on source ==== |
| 90 |
|
| 91 |
--echo # There should be no payload event. |
| 92 |
--let $keep_transaction_payload_events = 1 |
| 93 |
--source include/show_binlog_events.inc |
| 94 |
|
| 95 |
--let $measured_size = `SELECT SUM(LENGTH(x)) FROM t1` |
| 96 |
--let $assert_cond = $measured_size = $total_size |
| 97 |
--let $assert_text = The source's table size should equal the size of inserted data |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
--source include/sync_slave_sql_with_master.inc |
| 101 |
|
| 102 |
--echo ==== Verify result on replica ==== |
| 103 |
|
| 104 |
--let $measured_size = `SELECT SUM(LENGTH(x)) FROM t1` |
| 105 |
--let $assert_cond = $measured_size = $total_size |
| 106 |
--let $assert_text = The replica's table size should equal the size of inserted data |
| 107 |
--source include/assert.inc |
| 108 |
|
| 109 |
--echo |
| 110 |
--echo ==== Clean up scenario ==== |
| 111 |
|
| 112 |
--source include/rpl_connection_master.inc |
| 113 |
DROP TABLE t1; |
| 114 |
--source include/sync_slave_sql_with_master.inc |
| 115 |
|
| 116 |
--inc $c |
| 117 |
} |
| 118 |
|
| 119 |
--echo |
| 120 |
--echo ==== Clean up test case ==== |
| 121 |
|
| 122 |
--source include/rpl_connection_master.inc |
| 123 |
--source include/restore_sysvars.inc |
| 124 |
|
| 125 |
--source include/rpl_end.inc |