File: rpl_read_size.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (107 lines) | stat: -rw-r--r-- 3,799 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# It verifies that raising rpl_read_size option leads to less
# file reads in the relay log files when replicating small events.
#
# This test also verifies that data is consistent across master and slave
# even after dynamically changing the value of server variable
# rpl_read_size on slave.

# Reference: Bug #27147095: ADD RPL_READ_SIZE OPTION

# this test requires a deterministic transaction size to be
# handled by the slave. Therefore it is incompatible with
# compression.
--source include/not_binlog_transaction_compression_on.inc

# Test in this file is binlog format agnostic, thus no need
# to rerun it for every format.
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
CREATE TABLE t1(i INT, t LONGTEXT);

--source include/sync_slave_sql_with_master.inc
let $slave_rpl_read_size= `SELECT @@GLOBAL.rpl_read_size`;
# Here we are going to check the read count of relay log
# for two different inputs given to rpl_read_size.

--let $case= 0
while ($case < 2)
{
  # This is done to ensure that count_read is calculated
  # for the new relay log file.
  --source include/rpl_connection_master.inc
  INSERT INTO t1 VALUES (1, 'start');
  --source include/sync_slave_sql_with_master.inc

  # Avoid reading relay log file while receiving events
  --source include/stop_slave_sql.inc

  # Move to the next relay log. This will ensure that the count_read
  # variable will only contains the read done by belows INSERT query.
   --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)
  --source include/rpl_connection_master.inc

  --let $counter= 0
  --disable_query_log
  INSERT INTO t1 VALUES (1, lpad("foo", 7000, "bar"));
  while ($counter < 10)
  {
    INSERT INTO t1 SELECT * FROM t1;
    --inc $counter
  }
  TRUNCATE t1;
  --enable_query_log
  # Wait until all workload was replicated
  --source include/sync_slave_io_with_master.inc
  # Start reading from the relay log file
  START SLAVE SQL_THREAD;
  # Wait until all workload was read and applied
  --source include/sync_slave_sql_with_io.inc

  --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)

  --let $rpl_read_size_value= `SELECT @@GLOBAL.rpl_read_size`
  --let $relay_log_pos= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1)
  --let $expected_read_count= ` SELECT CEILING($relay_log_pos/$rpl_read_size_value)`
  --expr $count_read= $count_read_end - $count_read_start

  --let assert_text= "The expected read count and actual read count are same"
  --let assert_cond= $expected_read_count=$count_read
  --source include/assert.inc

  --echo The read count for @@GLOBAL.rpl_read_size= $rpl_read_size_value is  $count_read
  # change the read size for the next run.
  eval SET @@GLOBAL.rpl_read_size= 1048576;

  --source include/stop_slave.inc
  --source include/start_slave.inc
  --inc $case
}

# Test for checking the data consistency on changing
# rpl_read_size dynamically on slave side.

eval SET @@GLOBAL.rpl_read_size= $slave_rpl_read_size;

SET @@GLOBAL.rpl_read_size = 1048576;
SELECT @@GLOBAL.rpl_read_size;

FLUSH RELAY LOGS;
--source include/rpl_connection_master.inc

INSERT INTO t1 VALUES (0, "");
INSERT INTO t1 VALUES (1, lpad("foo", 7000, "bar"));

--source include/sync_slave_sql_with_master.inc
# Verify the contents of table t1 on slave.
# Should be same as contents in master.

--let $diff_tables=master:t1, slave:t1
--source include/diff_tables.inc


#Cleanup
eval SET @@GLOBAL.rpl_read_size= $slave_rpl_read_size;
--source include/rpl_connection_master.inc
DROP TABLE t1;
--source include/rpl_end.inc