Debian Codegraph @

mysql-test/suite/rpl/t/rpl_binlog_sender_packet_shrink.test

raw
1 # ==== Purpose ====
2 #
3 # This test will generate a big event and then will generate many small
4 # events, and will monitor the server memory consumption, observing the
5 # growth and the shrink of the binary log sender packet.
6 #
7 # ==== Related Bugs and Worklogs ====
8 #
9 # BUG#24643036 BINLOG_SENDER DOES NOT REDUCE SIZE OF SEND BUFFER AS EXPECTED
10 #
11 # Check-warnings times out on Sparc
12 --source include/not_sparc_debug.inc
13 # This test case is binary log format agnostic
14 --source include/have_binlog_format_row.inc
15 --source include/master-slave.inc
16 --source include/stop_dump_threads.inc
17
18 # this test requires some large events to be able to test
19 # buffer size dynamic behavior
20 --source include/not_binlog_transaction_compression_on.inc
21
22 --let $default_packet_size=`SELECT @@GLOBAL.net_buffer_length`
23
24 CREATE TABLE t1 (a TEXT(1048576));
25 --source include/sync_slave_sql_with_master.inc
26 --connection master
27 --let $tid= `SELECT THREAD_ID FROM performance_schema.threads WHERE PROCESSLIST_COMMAND LIKE "Binlog Dump%"`
28 --let $from_table= FROM performance_schema.memory_summary_by_thread_by_event_name
29 --let $from_clause= $from_table WHERE THREAD_ID = $tid AND EVENT_NAME LIKE 'memory/sql/String::value'
30 # The network packet is initialized with @@GLOBAL.net_buffer_length bytes.
31 # Calculate the baseline (just in case)
32 # BASELINE = (all) BYTES_USED - $default_packet_size
33 --let $baseline=`SELECT CURRENT_NUMBER_OF_BYTES_USED - $default_packet_size $from_clause`
34
35 --echo #
36 --echo # 1. Generate a big event to make the packet to grow
37 --echo #
38 --echo INSERT 1M byte string
39 --let $big= REPEAT('a', 1048576)
40 eval INSERT INTO t1 VALUES ($big);
41 --source include/sync_slave_sql_with_master.inc
42 --connection master
43 --let $last_packet_size= $default_packet_size
44 --let $current_packet_size= `SELECT CURRENT_NUMBER_OF_BYTES_USED - $baseline $from_clause`
45 # Use ROUND in the calculation to minimize the possibility of variation
46 --let $ratio= `SELECT ROUND($current_packet_size / $last_packet_size, 0)`
47 --let $assert_text= The packet should have grown 64 times after a 1M big event
48 --let $assert_cond= [ SELECT $ratio = 64 ]
49 --source include/assert.inc
50
51 --echo #
52 --echo # 2. Generate 100 events with some having more then 4097
53 --echo # bytes to ensure that the packet will shrink
54 --echo #
55 --let $trx_to_shrink= 20
56 --echo INSERT 20 x 8K string (x 5 events: GTID, BEGIN, TABLE_MAP, ROWS, XID)
57 --let $i= 0
58 --let $medium= REPEAT('b', 8192)
59 while ($i < $trx_to_shrink)
60 {
61 eval INSERT INTO t1 VALUES ($medium);
62 --inc $i
63 }
64 --source include/sync_slave_sql_with_master.inc
65 --connection master
66 --let $last_packet_size= $current_packet_size
67 --let $current_packet_size= `SELECT CURRENT_NUMBER_OF_BYTES_USED - $baseline $from_clause`
68
69 # We will tolerate a noise of $noise_tolerance bytes at each shrink assert
70 # probably just because of rounding and memory alignment.
71 --let $noise_tolerance= 16
72 --let $assert_text= The packet should be halved after 100 medium events
73 --let $assert_cond= $current_packet_size BETWEEN $last_packet_size/2 - $noise_tolerance AND $last_packet_size/2 + $noise_tolerance
74 --source include/assert.inc
75
76 --echo #
77 --echo # 3. Generate 700 events with some having less then 4096
78 --echo # bytes to ensure that the packet will shrink to
79 --echo # the minimum size.
80 --echo #
81 --echo INSERT 7 x 20 x 1K string (x 4 events: GTID, BEGIN, TABLE_MAP, ROWS, XID)
82 --let $b= 1
83 while ($b < 8)
84 {
85 --echo Iteration $b: INSERT 25 x 1K string (x 4 events: GTID, BEGIN, QUERY, XID)
86 --let $i= 0
87 --let $small= REPEAT('c', 1024)
88 while ($i < $trx_to_shrink)
89 {
90 eval INSERT INTO t1 VALUES ($small);
91 --inc $i
92 }
93 --source include/sync_slave_sql_with_master.inc
94 --connection master
95 --let $last_packet_size= $current_packet_size
96 --let $current_packet_size= `SELECT CURRENT_NUMBER_OF_BYTES_USED - $baseline $from_clause`
97 --let $assert_text= Iteration $b: The packet should be halved after 100 small events
98 --let $assert_cond= $current_packet_size BETWEEN $last_packet_size/2 - $noise_tolerance AND $last_packet_size/2 + $noise_tolerance
99 --source include/assert.inc
100 --inc $b
101 }
102
103 # Cleanup
104 DROP TABLE t1;
105 --source include/rpl_end.inc