Debian Codegraph @

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

raw
1 #
2 # It verifies that raising rpl_read_size option leads to less
3 # file reads in the relay log files when replicating small events.
4 #
5 # This test also verifies that data is consistent across master and slave
6 # even after dynamically changing the value of server variable
7 # rpl_read_size on slave.
8
9 # Reference: Bug #27147095: ADD RPL_READ_SIZE OPTION
10
11 # this test requires a deterministic transaction size to be
12 # handled by the slave. Therefore it is incompatible with
13 # compression.
14 --source include/not_binlog_transaction_compression_on.inc
15
16 # Test in this file is binlog format agnostic, thus no need
17 # to rerun it for every format.
18 --source include/have_binlog_format_row.inc
19 --source include/master-slave.inc
20 CREATE TABLE t1(i INT, t LONGTEXT);
21
22 --source include/sync_slave_sql_with_master.inc
23 let $slave_rpl_read_size= `SELECT @@GLOBAL.rpl_read_size`;
24 # Here we are going to check the read count of relay log
25 # for two different inputs given to rpl_read_size.
26
27 --let $case= 0
28 while ($case < 2)
29 {
30 # This is done to ensure that count_read is calculated
31 # for the new relay log file.
32 --source include/rpl_connection_master.inc
33 INSERT INTO t1 VALUES (1, 'start');
34 --source include/sync_slave_sql_with_master.inc
35
36 # Avoid reading relay log file while receiving events
37 --source include/stop_slave_sql.inc
38
39 # Move to the next relay log. This will ensure that the count_read
40 # variable will only contains the read done by belows INSERT query.
41 --let $count_read_start= query_get_value(SELECT count_read FROM performance_schema.file_summary_by_instance WHERE event_name='wait/io/file/sql/relaylog' ORDER BY file_name, count_read, 2)
42 --source include/rpl_connection_master.inc
43
44 --let $counter= 0
45 --disable_query_log
46 INSERT INTO t1 VALUES (1, lpad("foo", 7000, "bar"));
47 while ($counter < 10)
48 {
49 INSERT INTO t1 SELECT * FROM t1;
50 --inc $counter
51 }
52 TRUNCATE t1;
53 --enable_query_log
54 # Wait until all workload was replicated
55 --source include/sync_slave_io_with_master.inc
56 # Start reading from the relay log file
57 START SLAVE SQL_THREAD;
58 # Wait until all workload was read and applied
59 --source include/sync_slave_sql_with_io.inc
60
61 --let $count_read_end= query_get_value(SELECT count_read FROM performance_schema.file_summary_by_instance WHERE event_name='wait/io/file/sql/relaylog' ORDER BY file_name, count_read, 2)
62
63 --let $rpl_read_size_value= `SELECT @@GLOBAL.rpl_read_size`
64 --let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
65 --let $expected_read_count= ` SELECT CEILING($relay_log_pos/$rpl_read_size_value)`
66 --expr $count_read= $count_read_end - $count_read_start
67
68 --let assert_text= "The expected read count and actual read count are same"
69 --let assert_cond= $expected_read_count=$count_read
70 --source include/assert.inc
71
72 --echo The read count for @@GLOBAL.rpl_read_size= $rpl_read_size_value is $count_read
73 # change the read size for the next run.
74 eval SET @@GLOBAL.rpl_read_size= 1048576;
75
76 --source include/stop_slave.inc
77 --source include/start_slave.inc
78 --inc $case
79 }
80
81 # Test for checking the data consistency on changing
82 # rpl_read_size dynamically on slave side.
83
84 eval SET @@GLOBAL.rpl_read_size= $slave_rpl_read_size;
85
86 SET @@GLOBAL.rpl_read_size = 1048576;
87 SELECT @@GLOBAL.rpl_read_size;
88
89 FLUSH RELAY LOGS;
90 --source include/rpl_connection_master.inc
91
92 INSERT INTO t1 VALUES (0, "");
93 INSERT INTO t1 VALUES (1, lpad("foo", 7000, "bar"));
94
95 --source include/sync_slave_sql_with_master.inc
96 # Verify the contents of table t1 on slave.
97 # Should be same as contents in master.
98
99 --let $diff_tables=master:t1, slave:t1
100 --source include/diff_tables.inc
101
102
103 #Cleanup
104 eval SET @@GLOBAL.rpl_read_size= $slave_rpl_read_size;
105 --source include/rpl_connection_master.inc
106 DROP TABLE t1;
107 --source include/rpl_end.inc