| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test case will assert that a binary log file respect max_binlog_size |
| 4 |
# even when the encryption header is written to the files. |
| 5 |
# |
| 6 |
# It starts the servers with binlog_encryption = ON and max_binlog_size = 4096. |
| 7 |
# It then evaluates the size of a ROTATE event and the maximum size of a given |
| 8 |
# transaction pattern. |
| 9 |
# |
| 10 |
# It generates a workload of many transactions (enough to rotate the binary log |
| 11 |
# a few times), and finally it asserts that all binary log files are not larger |
| 12 |
# than max_binlog_size + max trx size + ROTATE size. |
| 13 |
# |
| 14 |
# ==== Related Bugs and Worklogs ==== |
| 15 |
# |
| 16 |
# WL#10957: Binary log encryption at rest |
| 17 |
# BUG#28663647 WHEN MAX_BINLOG_SIZE IS SET, EXTRA 512 BYTES OF THE HEADER IS |
| 18 |
# NOT CONSIDERED |
| 19 |
# |
| 20 |
|
| 21 |
# This test case is binary log format agnostic |
| 22 |
--source include/have_binlog_format_statement.inc |
| 23 |
--source include/master-slave.inc |
| 24 |
|
| 25 |
# this test needs to deterministically create a large enough binlog |
| 26 |
# file. Skip test when compression is on. |
| 27 |
--source include/not_binlog_transaction_compression_on.inc |
| 28 |
|
| 29 |
# Suppression of error messages |
| 30 |
#CALL mtr.add_suppression('Unsafe statement written to the binary log using statement format'); |
| 31 |
FLUSH LOGS; |
| 32 |
--let $assert_text=Rotate shall be the 3rd event in first binary log |
| 33 |
--let $assert_cond="[SHOW BINLOG EVENTS, Event_type, 3]" = "Rotate" |
| 34 |
--source include/assert.inc |
| 35 |
--let $rotate_start=query_get_value(SHOW BINLOG EVENTS, Pos, 3) |
| 36 |
--let $rotate_end=query_get_value(SHOW BINLOG EVENTS, End_log_pos, 3) |
| 37 |
--let $rotate_size=`SELECT $rotate_end - $rotate_start` |
| 38 |
|
| 39 |
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 VARCHAR(255)); |
| 40 |
|
| 41 |
--let $max_string=MySQLMySQLMySQLMySQLMySQL |
| 42 |
--let $trx=100 |
| 43 |
--echo # Inserting $trx transactions |
| 44 |
--disable_query_log |
| 45 |
# Get the trx size |
| 46 |
--let $pos_before=query_get_value(SHOW MASTER STATUS, Position, 1) |
| 47 |
--eval INSERT INTO t1 (c1, c2) VALUES ($trx, '$max_string') |
| 48 |
--let $pos_after=query_get_value(SHOW MASTER STATUS, Position, 1) |
| 49 |
--dec $trx |
| 50 |
while ($trx) |
| 51 |
{ |
| 52 |
--let $string=`SELECT LEFT('$max_string', RAND()*LENGTH('$max_string'))` |
| 53 |
--eval INSERT INTO t1 (c1, c2) VALUES ($trx, '$string') |
| 54 |
--dec $trx |
| 55 |
} |
| 56 |
--enable_query_log |
| 57 |
|
| 58 |
# Calculate the trx size |
| 59 |
--let $trx_size=`SELECT $pos_after - $pos_before` |
| 60 |
|
| 61 |
# No binlog shall be greater than max_binlog_size + trx_size + ROTATE |
| 62 |
--let $max_expected_size=`SELECT @@GLOBAL.max_binlog_size + $trx_size + $rotate_size` |
| 63 |
|
| 64 |
--let $binary_logs=query_get_value(SHOW MASTER STATUS, File, 1) |
| 65 |
--let $binary_logs=`SELECT RIGHT('$binary_logs', 6) - 0` |
| 66 |
--echo # Assert that all $binary_logs binary logs considered the encryption header |
| 67 |
while ($binary_logs) |
| 68 |
{ |
| 69 |
--let $binlog_size=query_get_value(SHOW BINARY LOGS, File_size, $binary_logs) |
| 70 |
--let $assert=`SELECT $binlog_size <= $max_expected_size` |
| 71 |
if (!$assert) |
| 72 |
{ |
| 73 |
SHOW BINARY LOGS; |
| 74 |
--echo At least one binary log was greater than @@GLOBAL.max_binlog_size + $trx_size + $rotate_size |
| 75 |
--die Test case failed an assertion |
| 76 |
} |
| 77 |
--dec $binary_logs |
| 78 |
} |
| 79 |
|
| 80 |
# Cleanup |
| 81 |
DROP TABLE t1; |
| 82 |
--source include/rpl_end.inc |