1
# BUG#46166: MYSQL_BIN_LOG::new_file_impl is not propagating error
2
# when generating new name.
7
# We want to check whether error is reported or not when
8
# new_file_impl fails (this may happen when rotation is not
9
# possible because there is some problem finding an
15
# Test cases are documented inline.
17
-- source include/have_innodb.inc
18
-- source include/have_debug.inc
19
-- source include/master-slave.inc
21
-- echo #######################################################################
22
-- echo ####################### PART 1: MASTER TESTS ##########################
23
-- echo #######################################################################
26
### ACTION: stopping slave as it is not needed for the first part of
30
-- source include/stop_slave.inc
33
call mtr.add_suppression("Can't generate a unique log-filename");
34
call mtr.add_suppression("Writing one row to the row-based binary log failed.*");
35
call mtr.add_suppression("Error writing file .*");
37
SET @old_debug= @@global.debug;
39
### ACTION: create a large file (> 4096 bytes) that will be later used
40
### in LOAD DATA INFILE to check binlog errors in its vacinity
41
-- let $load_file= $MYSQLTEST_VARDIR/tmp/bug_46166.data
42
-- let $MYSQLD_DATADIR= `select @@datadir`
43
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
44
-- eval SELECT repeat('x',8192) INTO OUTFILE '$load_file'
46
### ACTION: create a small file (< 4096 bytes) that will be later used
47
### in LOAD DATA INFILE to check for absence of binlog errors
48
### when file loading this file does not force flushing and
49
### rotating the binary log
50
-- let $load_file2= $MYSQLTEST_VARDIR/tmp/bug_46166-2.data
51
-- let $MYSQLD_DATADIR= `select @@datadir`
52
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
53
-- eval SELECT repeat('x',10) INTO OUTFILE '$load_file2'
57
-- echo ###################### TEST #1
59
### ASSERTION: no problem flushing logs (should show two binlogs)
61
-- echo # assert: must show two binlogs
62
-- source include/show_binary_logs.inc
64
-- echo ###################### TEST #2
66
### ASSERTION: check that FLUSH LOGS actually fails and reports
67
### failure back to the user if find_uniq_filename fails
68
### (should show just one binlog)
71
SET GLOBAL debug="+d,error_unique_log_filename";
72
-- error ER_NO_UNIQUE_LOGFILE
74
-- echo # assert: must show one binlog
75
-- source include/show_binary_logs.inc
77
### ACTION: clean up and move to next test
81
-- echo ###################### TEST #3
83
### ACTION: create some tables (t1, t2, t4) and insert some values in
85
CREATE TABLE t1 (a INT);
86
CREATE TABLE t2 (a VARCHAR(16384)) Engine=InnoDB;
87
CREATE TABLE t4 (a VARCHAR(16384));
88
INSERT INTO t1 VALUES (1);
91
### ASSERTION: we force rotation of the binary log because it exceeds
92
### the max_binlog_size option (should show two binary
95
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
96
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
98
# shows two binary logs
99
-- echo # assert: must show two binlog
100
-- source include/show_binary_logs.inc
102
# clean up the table and the binlog to be used in next part of test
103
SET GLOBAL debug="-d,error_unique_log_filename";
107
-- echo ###################### TEST #4
109
### ASSERTION: load the big file into a transactional table and check
110
### that it reports error. The table will contain the
111
### changes performed despite the fact that it reported an
114
SET GLOBAL debug="+d,error_unique_log_filename";
115
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
116
-- error ER_NO_UNIQUE_LOGFILE
117
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
120
-- echo # assert: must show one entry
121
SELECT count(*) FROM t2;
123
# clean up the table and the binlog to be used in next part of test
124
SET GLOBAL debug="-d,error_unique_log_filename";
128
-- echo ###################### TEST #5
130
### ASSERTION: load the small file into a transactional table and
131
### check that it succeeds
133
SET GLOBAL debug="+d,error_unique_log_filename";
134
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
135
-- eval LOAD DATA INFILE '$load_file2' INTO TABLE t2
138
-- echo # assert: must show one entry
139
SELECT count(*) FROM t2;
141
# clean up the table and the binlog to be used in next part of test
142
SET GLOBAL debug="-d,error_unique_log_filename";
146
-- echo ###################### TEST #6
148
### ASSERTION: check that even if one is using a transactional table
149
### and explicit transactions (no autocommit) if rotation
150
### fails we get the error. Transaction is not rolledback
151
### because rotation happens after the commit.
153
SET GLOBAL debug="+d,error_unique_log_filename";
155
INSERT INTO t2 VALUES ('muse');
156
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
157
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
158
INSERT INTO t2 VALUES ('muse');
159
-- error ER_NO_UNIQUE_LOGFILE
162
### ACTION: Show the contents of the table after the test
163
-- echo # assert: must show three entries
164
SELECT count(*) FROM t2;
166
### ACTION: clean up and move to the next test
168
SET GLOBAL debug="-d,error_unique_log_filename";
172
-- echo ###################### TEST #7
174
### ASSERTION: check that on a non-transactional table, if rotation
175
### fails then an error is reported and an incident event
176
### is written to the current binary log.
178
SET GLOBAL debug="+d,error_unique_log_filename";
179
SELECT count(*) FROM t4;
180
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
181
-- error ER_NO_UNIQUE_LOGFILE
182
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t4
184
-- echo # assert: must show 1 entry
185
SELECT count(*) FROM t4;
187
-- echo ### check that the incident event is written to the current log
188
SET GLOBAL debug="-d,error_unique_log_filename";
189
-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1)
190
-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
192
# 53 is the size of the incident event, so we start from 22 bytes before the
194
-- let $binlog_start = `SELECT $binlog_start - 53`
196
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start> $binlog_file BINLOG_FILE
197
-- replace_column 2 # 4 # 5 #
198
-- eval SHOW BINLOG EVENTS IN '$binlog_file' FROM $binlog_start LIMIT 1
200
# clean up and move to next test
204
-- echo ###################### TEST #8
206
### ASSERTION: check that statements end up in error but they succeed
207
### on changing the data.
209
SET GLOBAL debug="+d,error_unique_log_filename";
210
-- echo # must show 0 entries
211
SELECT count(*) FROM t4;
212
SELECT count(*) FROM t2;
214
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
215
-- error ER_NO_UNIQUE_LOGFILE
216
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t4
217
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
218
-- error ER_NO_UNIQUE_LOGFILE
219
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
220
-- error ER_NO_UNIQUE_LOGFILE
221
INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc');
223
-- echo # INFO: Count(*) Before Offending DELETEs
224
-- echo # assert: must show 1 entry
225
SELECT count(*) FROM t4;
226
-- echo # assert: must show 4 entries
227
SELECT count(*) FROM t2;
229
-- error ER_NO_UNIQUE_LOGFILE
231
-- error ER_NO_UNIQUE_LOGFILE
234
-- echo # INFO: Count(*) After Offending DELETEs
235
-- echo # assert: must show zero entries
236
SELECT count(*) FROM t4;
237
SELECT count(*) FROM t2;
239
# remove fault injection
240
SET GLOBAL debug="-d,error_unique_log_filename";
242
-- echo ###################### TEST #9
244
### ASSERTION: check that if we disable binlogging, then statements
246
SET GLOBAL debug="+d,error_unique_log_filename";
248
INSERT INTO t2 VALUES ('aaa'), ('bbb'), ('ccc'), ('ddd');
249
INSERT INTO t4 VALUES ('eee'), ('fff'), ('ggg'), ('hhh');
250
-- echo # assert: must show four entries
251
SELECT count(*) FROM t2;
252
SELECT count(*) FROM t4;
255
-- echo # assert: must show zero entries
256
SELECT count(*) FROM t2;
257
SELECT count(*) FROM t4;
259
SET GLOBAL debug="-d,error_unique_log_filename";
261
-- echo ###################### TEST #10
263
### ASSERTION: check that error is reported if there is a failure
264
### while registering the index file and the binary log
265
### file or failure to write the rotate event.
267
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
268
call mtr.add_suppression("Could not open .*");
273
# +d,fault_injection_registering_index => injects fault on MYSQL_BIN_LOG::open
274
SET GLOBAL debug="+d,fault_injection_registering_index";
275
-- replace_regex /\.[\\\/]master/master/
276
-- error ER_CANT_OPEN_FILE
278
SET GLOBAL debug="-d,fault_injection_registering_index";
280
-- error ER_NO_BINARY_LOGGING
283
# issue some statements and check that they don't fail
284
CREATE TABLE t5 (a INT);
285
INSERT INTO t4 VALUES ('bbbbb');
286
INSERT INTO t2 VALUES ('aaaaa');
291
-- echo ###################### TEST #11
293
### ASSERTION: check that error is reported if there is a failure
294
### while opening the index file and the binary log file or
295
### failure to write the rotate event.
297
# restart the server so that we have binlog again
298
--let $rpl_server_number= 1
299
--source include/rpl_restart_server.inc
301
# +d,fault_injection_openning_index => injects fault on MYSQL_BIN_LOG::open_index_file
302
SET GLOBAL debug="+d,fault_injection_openning_index";
303
-- replace_regex /\.[\\\/]master/master/
304
-- error ER_CANT_OPEN_FILE
306
SET GLOBAL debug="-d,fault_injection_openning_index";
308
-- error ER_FLUSH_MASTER_BINLOG_CLOSED
311
# issue some statements and check that they don't fail
312
CREATE TABLE t5 (a INT);
313
INSERT INTO t4 VALUES ('bbbbb');
314
INSERT INTO t2 VALUES ('aaaaa');
319
# restart the server so that we have binlog again
320
--let $rpl_server_number= 1
321
--source include/rpl_restart_server.inc
323
-- echo ###################### TEST #12
325
### ASSERTION: check that error is reported if there is a failure
326
### while writing the rotate event when creating a new log
329
# +d,fault_injection_new_file_rotate_event => injects fault on MYSQL_BIN_LOG::MYSQL_BIN_LOG::new_file_impl
330
SET GLOBAL debug="+d,fault_injection_new_file_rotate_event";
331
-- error ER_ERROR_ON_WRITE
333
SET GLOBAL debug="-d,fault_injection_new_file_rotate_event";
335
-- error ER_FLUSH_MASTER_BINLOG_CLOSED
338
# issue some statements and check that they don't fail
339
CREATE TABLE t5 (a INT);
340
INSERT INTO t4 VALUES ('bbbbb');
341
INSERT INTO t2 VALUES ('aaaaa');
346
# restart the server so that we have binlog again
347
--let $rpl_server_number= 1
348
--source include/rpl_restart_server.inc
351
SET GLOBAL debug= @old_debug;
352
DROP TABLE t1, t2, t4;
355
# restart slave again
357
-- source include/start_slave.inc
360
-- echo #######################################################################
361
-- echo ####################### PART 2: SLAVE TESTS ###########################
362
-- echo #######################################################################
365
--source include/rpl_reset.inc
370
call mtr.add_suppression("Slave I/O: Relay log write failure: could not queue event from master.*");
371
call mtr.add_suppression("Error writing file .*");
372
call mtr.add_suppression("Could not open .*");
373
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
374
call mtr.add_suppression("Can't generate a unique log-filename .*");
375
-- echo ###################### TEST #13
377
#### ASSERTION: check against unique log filename error
378
-- let $io_thd_injection_fault_flag= error_unique_log_filename
379
-- let $slave_io_errno= 1595
380
-- let $show_slave_io_error= 1
381
-- source include/io_thd_fault_injection.inc
383
-- echo ###################### TEST #14
385
#### ASSERTION: check against rotate failing
386
-- let $io_thd_injection_fault_flag= fault_injection_new_file_rotate_event
387
-- let $slave_io_errno= 1595
388
-- let $show_slave_io_error= 1
389
-- source include/io_thd_fault_injection.inc
391
-- echo ###################### TEST #15
393
#### ASSERTION: check against relay log open failure
394
-- let $io_thd_injection_fault_flag= fault_injection_registering_index
395
-- let $slave_io_errno= 1595
396
-- let $show_slave_io_error= 1
397
-- source include/io_thd_fault_injection.inc
399
-- echo ###################### TEST #16
401
#### ASSERTION: check against relay log index open failure
402
-- let $io_thd_injection_fault_flag= fault_injection_openning_index
403
-- let $slave_io_errno= 1595
404
-- let $show_slave_io_error= 1
405
-- source include/io_thd_fault_injection.inc
408
-- source include/stop_slave_sql.inc
409
SET GLOBAL debug=@old_debug;
412
--let $rpl_only_running_threads= 1
413
--source include/rpl_end.inc