Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Test the server behaviour when `mysql.gtid_executed` is read-only and the
4 # binary log has to be rotated.
5 #
6 # ==== Requirements ====
7 #
8 # R1. If `mysql.gtid_executed` table is read-only and binlog rotation is
9 # triggered by any other means than `max_binlog_size` being reached, the
10 # server should:
11 # 1) Log a warning to the server.
12 # 2) send an error to the client, if rotate was triggered by the execution
13 # of a statement.
14 # 3) Keep logging to the currently opened binary log.
15 #
16 # R2. If `mysql.gtid_executed` table is read-only, `binlog_error_action` is
17 # `IGNORE_ERROR` and binlog rotation is triggered by `max_binlog_size` being
18 # reached, the server should:
19 # 1) Log an error to the server log.
20 # 2) Send an error to the client, if rotate was triggered by the execution
21 # of a statement.
22 # 3) Stop binary logging for the all duration of the server current
23 # execution process.
24 #
25 # R3. If `mysql.gtid_executed` table is read-only, `binlog_error_action` is
26 # `ABORT_SERVER` and binlog rotation is triggered by `max_binlog_size` being
27 # reached, the server should:
28 # 1) Log an error to the server log.
29 # 2) Send an error to the client, if rotate was triggered by the execution
30 # of a statement.
31 # 3) Abort the current server execution process.
32 #
33 # ==== Implementation ====
34 #
35 # TC1. Table `mysql.gtid_executed` read-only & rotate not triggered by
36 # `max_binlog_size`
37 # --------------------------------------------------------------------
38 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
39 # `mysql.gtid_executed` read-only behaviour.
40 # 2) Execute `FLUSH BINARY LOGS` and expect failure with
41 # `ER_BINLOG_UNABLE_TO_ROTATE_GTID_TABLE_READONLY`.
42 # 3) Assert that binary log didn't rotate.
43 # 4) Assert that an error was logged to the server log.
44 #
45 # TC2. Table `mysql.gtid_executed` read-only & rotate triggered by
46 # `max_binlog_size` & `binlog_error_action` is `IGNORE_ERROR`
47 # ----------------------------------------------------------------
48 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
49 # `mysql.gtid_executed` read-only behaviour.
50 # 2) Add `DEBUG` sync point, `simulate_max_binlog_size` to simulate that
51 # `max_binlog_size` limit was reached.
52 # 3) Execute `FLUSH BINARY LOGS` and expect failure with
53 # `ER_RPL_GTID_TABLE_CANNOT_OPEN`.
54 # 4) Assert that binary log didn't rotate.
55 # 5) Assert that an error was logged to the server log.
56 #
57 # TC3. Table `mysql.gtid_executed` read-only & rotate triggered by
58 # `max_binlog_size` & `binlog_error_action` is `ABORT_SERVER`
59 # ----------------------------------------------------------------
60 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
61 # `mysql.gtid_executed` read-only behaviour.
62 # 2) Add `DEBUG` sync point, `simulate_max_binlog_size` to simulate that
63 # `max_binlog_size` limit was reached.
64 # 3) Execute `FLUSH BINARY LOGS` and expect failure with
65 # `ER_BINLOG_LOGGING_IMPOSSIBLE`.
66 # 4) Assert that binary log didn't rotate.
67 # 5) Assert that an error was logged to the server log.
68 #
69 # ==== References ====
70 #
71 # BUG#29111514 FLUSHING BINARY LOGS WITH GTID LEADS TO AN OOM ERROR
72 #
73
74 --source include/not_valgrind.inc
75 --source include/have_debug.inc
76 --source include/have_debug_sync.inc
77 --source include/have_log_bin.inc
78
79 --let $initial_debug = "`SELECT @@DEBUG`"
80 --let $initial_error_action = `SELECT @@binlog_error_action`
81 --let $pattern_to_match = $MYSQLTEST_VARDIR/mysqld.1/data/*binlog*.0*
82 --let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err
83
84 --echo #
85 --echo # TC1. Table `mysql.gtid_executed` read-only & rotate not triggered by `max_binlog_size`
86 --echo #
87
88 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
89 # `mysql.gtid_executed` read-only behaviour.
90 SET DEBUG = "d,gtid_executed_readonly";
91
92 CALL mtr.add_suppression("Unable to create a new binlog file.");
93 CALL mtr.add_suppression(".Turning logging off for the whole duration of the MySQL server process.");
94 CALL mtr.add_suppression(".Gtid table is not ready to be used.");
95
96 # 2) Execute `FLUSH BINARY LOGS` and expect failure with
97 # `ER_BINLOG_UNABLE_TO_ROTATE_GTID_TABLE_READONLY`.
98 --source include/rpl_log_file_max_number.inc
99 --let $max_log_file_before_flush = $log_file_max_number
100
101 --error ER_DA_RPL_GTID_TABLE_CANNOT_OPEN
102 FLUSH BINARY LOGS;
103
104 # 3) Assert that binary log didn't rotate.
105 --source include/rpl_log_file_max_number.inc
106 --let $max_log_file_after_flush = $log_file_max_number
107 --let $assert_text = 'FLUSH BINARY LOGS' failed to rotate binlog
108 --let $assert_cond = $max_log_file_before_flush = $max_log_file_after_flush
109 --source include/assert.inc
110
111 # 4) Assert that an error was logged to the server log.
112 --let $assert_select = Unable to create a new binlog file
113 --let $assert_match = (.*)$assert_select(.*)
114 --let $assert_text = ER_BINLOG_UNABLE_TO_ROTATE_GTID_TABLE_READONLY found in server log
115 --source include/assert_grep.inc
116
117 --echo #
118 --echo # TC2. Table `mysql.gtid_executed` read-only & rotate triggered by `max_binlog_size` & `binlog_error_action` is `IGNORE_ERROR`
119 --echo #
120 SET GLOBAL binlog_error_action = IGNORE_ERROR;
121
122 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
123 # `mysql.gtid_executed` read-only behaviour.
124 # 2) Add `DEBUG` sync point, `simulate_max_binlog_size` to simulate that
125 # `max_binlog_size` limit was reached.
126 SET DEBUG = "d,gtid_executed_readonly,simulate_max_binlog_size";
127
128 # 3) Execute `FLUSH BINARY LOGS` and expect failure with
129 # `ER_RPL_GTID_TABLE_CANNOT_OPEN`.
130 --source include/rpl_log_file_max_number.inc
131 --let $max_log_file_before_flush = $log_file_max_number
132
133 --error ER_DA_RPL_GTID_TABLE_CANNOT_OPEN
134 FLUSH BINARY LOGS;
135
136 # 4) Assert that binary log didn't rotate.
137 --source include/rpl_log_file_max_number.inc
138 --let $max_log_file_after_flush = $log_file_max_number
139 --let $assert_text = 'FLUSH BINARY LOGS' failed to rotate binlog
140 --let $assert_cond = $max_log_file_before_flush = $max_log_file_after_flush
141 --source include/assert.inc
142
143 # 5) Assert that an error was logged to the server log.
144 --let $assert_select = Turning logging off for the whole duration of the MySQL server process
145 --let $assert_match = (.*)$assert_select(.*)
146 --let $assert_text = ER_BINLOG_CANT_OPEN_FOR_LOGGING found in server log
147 --source include/assert_grep.inc
148
149 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
150 --shutdown_server 0
151 --source include/wait_until_disconnected.inc
152 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
153 --enable_reconnect
154 --source include/wait_until_connected_again.inc
155
156 --echo #
157 --echo # TC3. Table `mysql.gtid_executed` read-only & rotate triggered by `max_binlog_size` & `binlog_error_action` is `ABORT_SERVER`
158 --echo #
159 SET GLOBAL binlog_error_action = ABORT_SERVER;
160
161 CALL mtr.add_suppression("Unable to create a new binlog file.");
162 CALL mtr.add_suppression(".Turning logging off for the whole duration of the MySQL server process.");
163 CALL mtr.add_suppression(".Gtid table is not ready to be used.");
164 CALL mtr.add_suppression(".");
165
166 # 1) Add `DEBUG` sync point, `gtid_executed_readonly` to simulate
167 # `mysql.gtid_executed` read-only behaviour.
168 # 2) Add `DEBUG` sync point, `simulate_max_binlog_size` to simulate that
169 # `max_binlog_size` limit was reached.
170 SET DEBUG = "d,gtid_executed_readonly,simulate_max_binlog_size";
171 --source include/rpl_log_file_max_number.inc
172 --let $max_log_file_before_flush = $log_file_max_number
173
174 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
175
176 # 3) Execute `FLUSH BINARY LOGS` and expect failure with
177 # `ER_BINLOG_LOGGING_IMPOSSIBLE`.
178 --error ER_BINLOG_LOGGING_IMPOSSIBLE
179 FLUSH BINARY LOGS;
180
181 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
182 --enable_reconnect
183 --source include/wait_until_connected_again.inc
184
185 # 4) Assert that binary log didn't rotate.
186 --source include/rpl_log_file_max_number.inc
187 --let $max_log_file_after_flush = $log_file_max_number
188 --let $offset = 1
189 --expr $expected_max_log_file_after_flush = $max_log_file_before_flush + $offset
190 --let $assert_text = 'FLUSH BINARY LOGS' failed to rotate binlog but as the server restarts, the binary log is rotated
191 --let $assert_cond = $max_log_file_after_flush = $expected_max_log_file_after_flush
192 --source include/assert.inc
193
194 # 5) Assert that an error was logged to the server log.
195 --let $assert_select = Table 'mysql.gtid_executed' cannot be opened., while rotating the binlog. Aborting the server
196 --let $assert_match = (.*)$assert_select(.*)
197 --let $assert_text = ER_BINLOG_LOGGING_IMPOSSIBLE found in server log
198 --source include/assert_grep.inc
199
200 # Clean up
201 --replace_result $initial_debug INITIAL_DEBUG
202 --eval SET DEBUG = $initial_debug
203 --replace_result $initial_error_action INITIAL_ERROR_ACTION
204 --eval SET GLOBAL binlog_error_action = $initial_error_action