| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test case test verifies that no unwanted fseeks are done by dump threads |
| 4 |
# reading the binary log file sequentially. Dump threads should not change |
| 5 |
# COUNT_MISC after started dumping a binary log file, until moving to dumping |
| 6 |
# another binary log file. |
| 7 |
# |
| 8 |
# This test will create a set of transactions which event headers would, |
| 9 |
# sometimes, cross the IO_CACHE block size. After running the workload, the test |
| 10 |
# case will verify the P_S counter COUNT_MISC for "wait/io/file/sql/binlog" |
| 11 |
# EVENT_NAME at performance_schema.file_summary_by_event_name. In a single |
| 12 |
# binary log file case, the counter should not be more than 6 (as there are some |
| 13 |
# real file operations opening the binary log file and pointing it to the first |
| 14 |
# event position) or 9 in the case of GTIDs be enabled with auto positioning. |
| 15 |
# |
| 16 |
# ==== Related Bugs and Worklogs ==== |
| 17 |
# |
| 18 |
# BUG#24763579 BINLOG SENDER IS GENERATING UNWANTED FSEEKS ON BINARY LOG FILE |
| 19 |
# |
| 20 |
# It was noticed that the binlog sender was reading the event reader (19 bytes) |
| 21 |
# to get the event size and was doing a "fseek" on the IO_CACHE to the beginning |
| 22 |
# of the event, as the event would be fully read later, after adjusting the |
| 23 |
# network packet size to fit the whole event. |
| 24 |
# |
| 25 |
# As the IO_CACHE read the files using an 8K block (for reads smaller than 8K), |
| 26 |
# when the event header crossed the block boundaries, the "fseek" needed to |
| 27 |
# be performed on file level (and not only at IO_CACHE buffer level), generating |
| 28 |
# a call to the OS that resulted in an unwanted wait. |
| 29 |
# |
| 30 |
|
| 31 |
# This test case was designed to run with SBR |
| 32 |
--source include/have_binlog_format_statement.inc |
| 33 |
--let $rpl_skip_start_slave= 1 |
| 34 |
--source include/master-slave.inc |
| 35 |
--source include/stop_dump_threads.inc |
| 36 |
|
| 37 |
################################################## |
| 38 |
# Some variable to help calculating the workload # |
| 39 |
################################################## |
| 40 |
# IO_CACHE block size |
| 41 |
--let $block_size= 8192 |
| 42 |
# How many bytes of the header should be at the end of a block |
| 43 |
--let $border= 2 |
| 44 |
# We must fit many events into a block size |
| 45 |
--let $event_factor= 8 |
| 46 |
|
| 47 |
################################################ |
| 48 |
# Preparing the master for the larger workload # |
| 49 |
################################################ |
| 50 |
--eval CREATE TABLE t1 (c1 TEXT($block_size)) |
| 51 |
|
| 52 |
# Get current binlog position |
| 53 |
--let $init_master_pos= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 54 |
|
| 55 |
--let $ref_size= `SELECT $block_size DIV $event_factor` |
| 56 |
--let $content= `SELECT REPEAT('x', $ref_size)` |
| 57 |
--disable_query_log |
| 58 |
--echo Inserting a reference transaction to calculate the content size |
| 59 |
--eval INSERT INTO t1 VALUES ("$content") |
| 60 |
--enable_query_log |
| 61 |
|
| 62 |
# Calculate the "transaction payload" (all but the insert content) |
| 63 |
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 64 |
--let $trx_base_size= `SELECT ($master_pos - $init_master_pos) - $ref_size` |
| 65 |
|
| 66 |
# Prepare a transaction to left the binlog at the border of a block |
| 67 |
--let $content_size= `SELECT (($block_size - $border) - $trx_base_size) - $master_pos` |
| 68 |
--let $content= `SELECT REPEAT('x', $content_size)` |
| 69 |
--disable_query_log |
| 70 |
--echo Filling binary log up to the border of the $block_size block |
| 71 |
--eval INSERT INTO t1 VALUES ("$content") |
| 72 |
--enable_query_log |
| 73 |
|
| 74 |
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 75 |
--let $assert_text= The binary log is at the expected border of a $block_size block |
| 76 |
--let $assert_cond= $border = ($block_size - ( $master_pos % $block_size )) |
| 77 |
--source include/assert.inc |
| 78 |
|
| 79 |
# Prepare a transaction content for the large workload |
| 80 |
--let $content_size= `SELECT (($block_size DIV $event_factor) - $trx_base_size)` |
| 81 |
--let $content= `SELECT REPEAT('x', $content_size)` |
| 82 |
|
| 83 |
###################### |
| 84 |
# The large workload # |
| 85 |
###################### |
| 86 |
--let $counter=100 |
| 87 |
--echo Filling the binary log $counter transactions |
| 88 |
--disable_query_log |
| 89 |
while ($counter) |
| 90 |
{ |
| 91 |
--eval INSERT INTO t1 VALUES ("$content") |
| 92 |
--dec $counter |
| 93 |
} |
| 94 |
--enable_query_log |
| 95 |
|
| 96 |
################################################ |
| 97 |
# Sync slave I/O thread and check the counters # |
| 98 |
################################################ |
| 99 |
TRUNCATE performance_schema.file_summary_by_event_name; |
| 100 |
|
| 101 |
# Sync slave I/O thread |
| 102 |
--source include/rpl_connection_slave.inc |
| 103 |
--source include/start_slave_io.inc |
| 104 |
--source include/rpl_connection_master.inc |
| 105 |
--source include/sync_slave_io_with_master.inc |
| 106 |
|
| 107 |
# Check the COUNT_MISC counter |
| 108 |
--source include/rpl_connection_master.inc |
| 109 |
# In a first run, the counter tops 6 without GTIDs, and tops 9 when GTIDs are |
| 110 |
# enabled, because of the process of searching the binary log file that |
| 111 |
# contains the first GTID not yet retrieved/executed by the slave. |
| 112 |
--let $expected_count_misc= 6 |
| 113 |
if ($use_gtids) |
| 114 |
{ |
| 115 |
--let $expected_count_misc= 9 |
| 116 |
} |
| 117 |
|
| 118 |
--let $current_count_misc=`SELECT COUNT_MISC FROM performance_schema.file_summary_by_event_name WHERE EVENT_NAME = "wait/io/file/sql/binlog"` |
| 119 |
|
| 120 |
--let $assert_text= COUNT_MISC for "wait/io/file/sql/binlog" should be minimal |
| 121 |
--let $assert_cond= $current_count_misc = $expected_count_misc |
| 122 |
--let $extra_debug_eval= $current_count_misc AS current_count_misc, $expected_count_misc as expected_count_misc |
| 123 |
--let $extra_debug_info= COUNT_MISC should be 6 for non-GTID and 9 for GTID enabled servers |
| 124 |
--source include/assert.inc |
| 125 |
|
| 126 |
# Cleanup |
| 127 |
--source include/rpl_connection_slave.inc |
| 128 |
--source include/start_slave_sql.inc |
| 129 |
--source include/rpl_connection_master.inc |
| 130 |
DROP TABLE t1; |
| 131 |
--source include/rpl_end.inc |