Debian Codegraph @

mysql-test/suite/binlog_gtid/t/binlog_gtid_accessible_table_with_readonly.test

raw
1 # ==== Purpose ====
2 #
3 # Test the server behaviour when `read_only` or `super_read_only` modes are
4 # enabled and the binary log has to be rotated.
5 #
6 # ==== Requirements ====
7 #
8 # R1. If `read_only` mode is enabled, binlog rotation MUST NOT fail because of
9 # it.
10 #
11 # R2. If `super_read_only` mode is enabled, binlog rotation MUST NOT fail
12 # because of it.
13 #
14 # ==== Implementation ====
15 #
16 # TC1. Variable `read_only` is ON & rotate the binlog
17 # ------------------------------------------------------------------------
18 # 1) Set `read_only` to ON
19 # 2) Execute `FLUSH BINARY LOGS` and expect success.
20 # 3) Assert that binary log rotated.
21 #
22 # TC2. Variable `super_read_only` is ON & rotate the binlog
23 # ------------------------------------------------------------------------
24 # 1) Set `super_read_only` to ON
25 # 2) Execute `FLUSH BINARY LOGS` and expect success.
26 # 3) Assert that binary log rotated.
27 #
28 # TC3. Variable `read_only` is ON & simulate max binlog size reached
29 # ------------------------------------------------------------------------
30 # 1) Set `read_only` to ON
31 # 2) Add `DEBUG` sync point, `simulate_max_binlog_size` to simulate that
32 # `max_binlog_size` limit was reached.
33 # 3) Execute DDL statement and expect success.
34 # 4) Assert that binary log rotated.
35 #
36 # ==== References ====
37 #
38 # BUG#29111514 FLUSHING BINARY LOGS WITH GTID LEADS TO AN OOM ERROR
39 #
40
41 --source include/have_debug.inc
42 --source include/have_log_bin.inc
43
44 --let $pattern_to_match = $MYSQLTEST_VARDIR/mysqld.1/data/*binlog*.0*
45
46 --let $initial_read_only = `SELECT IF(@@read_only, "ON", "OFF")`
47 --let $initial_super_read_only = `SELECT IF(@@super_read_only, "ON", "OFF")`
48
49 --let $tc = 1
50 while ($tc != 3) {
51
52 if ($tc == 1) {
53 --let $option = read_only
54 }
55 if ($tc == 2) {
56 --let $option = super_read_only
57 }
58
59 --echo #
60 --echo # TC$tc. Variable `$option` is ON & rotate the binlog
61 --echo #
62
63 # 1) Set option to ON
64 --let $initial_option = `SELECT IF(@@$option, "ON", "OFF")`
65 --eval SET GLOBAL $option = ON
66
67 --source include/rpl_log_file_max_number.inc
68 --let $max_log_file_before_flush = $log_file_max_number
69
70 # 2) Execute `FLUSH BINARY LOGS` and expect success.
71 FLUSH BINARY LOGS;
72
73 # 3) Assert that binary log rotated.
74 --source include/rpl_log_file_max_number.inc
75 --let $max_log_file_after_flush = $log_file_max_number
76 --let $offset = 1
77 --expr $expected_max_log_file_after_flush = $max_log_file_before_flush + $offset
78 --let $assert_text = 'FLUSH BINARY LOGS' rotated the binlog with '$option=ON'
79 --let $assert_cond = $max_log_file_after_flush = $expected_max_log_file_after_flush
80 --source include/assert.inc
81
82 # Clean up
83 --replace_result $initial_option INITIAL_OPTION_VALUE
84 --eval SET GLOBAL $option = $initial_option
85
86 --inc $tc
87 }
88
89 # Clean up
90 --replace_result $initial_read_only INITIAL_OPTION_VALUE
91 --eval SET GLOBAL read_only = $initial_read_only
92 --replace_result $initial_super_read_only INITIAL_OPTION_VALUE
93 --eval SET GLOBAL super_read_only = $initial_super_read_only
94
95 --let $option = read_only
96 --echo #
97 --echo # TC$tc. Variable `$option` is ON & simulate max binlog size reached
98 --echo #
99
100 # 1) Set option to ON
101 --let $initial_option = `SELECT IF(@@$option, "ON", "OFF")`
102 --eval SET GLOBAL $option = ON
103
104 --source include/rpl_log_file_max_number.inc
105 --let $max_log_file_before_flush = $log_file_max_number
106
107 # 2) Execute DDL and expect success.
108 SET DEBUG = "d,simulate_max_binlog_size";
109 DROP PROCEDURE IF EXISTS p1;
110
111 # 3) Assert that binary log rotated.
112 --source include/rpl_log_file_max_number.inc
113 --let $max_log_file_after_flush = $log_file_max_number
114 --let $offset = 1
115 --expr $expected_max_log_file_after_flush = $max_log_file_before_flush + $offset
116 --let $assert_text = Having '$option=ON' didnot prevent the binlog of rotating when `max_binlog_size` is reached
117 --let $assert_cond = $max_log_file_after_flush = $expected_max_log_file_after_flush
118 --source include/assert.inc
119
120 # Clean up
121 --replace_result $initial_option INITIAL_OPTION_VALUE
122 --eval SET GLOBAL $option = $initial_option
123
124 # Clean up
125 --replace_result $initial_read_only INITIAL_OPTION_VALUE
126 --eval SET GLOBAL read_only = $initial_read_only
127 --replace_result $initial_super_read_only INITIAL_OPTION_VALUE
128 --eval SET GLOBAL super_read_only = $initial_super_read_only