~ubuntu-branches/ubuntu/natty/mysql-5.1/natty-proposed

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_binlog_errors.test

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 08:30:45 UTC
  • mfrom: (1.4.1)
  • Revision ID: package-import@ubuntu.com-20120222083045-2rd53r4bnyx7qus4
Tags: 5.1.61-0ubuntu0.11.04.1
* SECURITY UPDATE: Update to 5.1.61 to fix multiple security issues
  (LP: #937869)
  - http://www.oracle.com/technetwork/topics/security/cpujan2012-366304.html
  - CVE-2011-2262
  - CVE-2012-0075
  - CVE-2012-0112
  - CVE-2012-0113
  - CVE-2012-0114
  - CVE-2012-0115
  - CVE-2012-0116
  - CVE-2012-0117
  - CVE-2012-0118
  - CVE-2012-0119
  - CVE-2012-0120
  - CVE-2012-0484
  - CVE-2012-0485
  - CVE-2012-0486
  - CVE-2012-0487
  - CVE-2012-0488
  - CVE-2012-0489
  - CVE-2012-0490
  - CVE-2012-0491
  - CVE-2012-0492
  - CVE-2012-0493
  - CVE-2012-0494
  - CVE-2012-0495
  - CVE-2012-0496

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# BUG#46166: MYSQL_BIN_LOG::new_file_impl is not propagating error
 
2
#            when generating new name.
 
3
#  
 
4
# WHY
 
5
# ===
 
6
#
 
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 
 
10
# unique filename).
 
11
#
 
12
# HOW
 
13
# ===
 
14
 
15
# Test cases are documented inline.
 
16
 
 
17
-- source include/have_innodb.inc
 
18
-- source include/have_debug.inc
 
19
-- source include/master-slave.inc
 
20
 
 
21
-- echo #######################################################################
 
22
-- echo ####################### PART 1: MASTER TESTS ##########################
 
23
-- echo #######################################################################
 
24
 
 
25
 
 
26
### ACTION: stopping slave as it is not needed for the first part of
 
27
###         the test
 
28
 
 
29
-- connection slave
 
30
-- source include/stop_slave.inc
 
31
-- connection master
 
32
 
 
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 .*");
 
36
 
 
37
SET @old_debug= @@global.debug;
 
38
 
 
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'
 
45
 
 
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'
 
54
 
 
55
RESET MASTER;
 
56
 
 
57
-- echo ###################### TEST #1
 
58
 
 
59
### ASSERTION: no problem flushing logs (should show two binlogs)
 
60
FLUSH LOGS;
 
61
-- echo # assert: must show two binlogs
 
62
-- source include/show_binary_logs.inc
 
63
 
 
64
-- echo ###################### TEST #2
 
65
 
 
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)
 
69
 
 
70
RESET MASTER;
 
71
SET GLOBAL debug="+d,error_unique_log_filename";
 
72
-- error ER_NO_UNIQUE_LOGFILE
 
73
FLUSH LOGS;
 
74
-- echo # assert: must show one binlog
 
75
-- source include/show_binary_logs.inc
 
76
 
 
77
### ACTION: clean up and move to next test
 
78
SET GLOBAL debug="";
 
79
RESET MASTER;
 
80
 
 
81
-- echo ###################### TEST #3
 
82
 
 
83
### ACTION: create some tables (t1, t2, t4) and insert some values in
 
84
###         table t1
 
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);
 
89
RESET MASTER;
 
90
 
 
91
### ASSERTION: we force rotation of the binary log because it exceeds
 
92
###            the max_binlog_size option (should show two binary
 
93
###            logs)
 
94
 
 
95
-- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
 
96
-- eval LOAD DATA INFILE '$load_file' INTO TABLE t2
 
97
 
 
98
# shows two binary logs
 
99
-- echo # assert: must show two binlog
 
100
-- source include/show_binary_logs.inc
 
101
 
 
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";
 
104
DELETE FROM t2;
 
105
RESET MASTER;
 
106
 
 
107
-- echo ###################### TEST #4
 
108
 
 
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
 
112
###            error.
 
113
 
 
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
 
118
 
 
119
# show table 
 
120
-- echo # assert: must show one entry
 
121
SELECT count(*) FROM t2;
 
122
 
 
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";
 
125
DELETE FROM t2;
 
126
RESET MASTER;
 
127
 
 
128
-- echo ###################### TEST #5
 
129
 
 
130
### ASSERTION: load the small file into a transactional table and
 
131
###            check that it succeeds
 
132
 
 
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
 
136
 
 
137
# show table 
 
138
-- echo # assert: must show one entry
 
139
SELECT count(*) FROM t2;
 
140
 
 
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";
 
143
DELETE FROM t2;
 
144
RESET MASTER;
 
145
 
 
146
-- echo ###################### TEST #6
 
147
 
 
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.
 
152
 
 
153
SET GLOBAL debug="+d,error_unique_log_filename";
 
154
SET AUTOCOMMIT=0;
 
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
 
160
COMMIT;
 
161
 
 
162
### ACTION: Show the contents of the table after the test 
 
163
-- echo # assert: must show three entries
 
164
SELECT count(*) FROM t2;
 
165
 
 
166
### ACTION: clean up and move to the next test 
 
167
SET AUTOCOMMIT= 1;
 
168
SET GLOBAL debug="-d,error_unique_log_filename";
 
169
DELETE FROM t2;
 
170
RESET MASTER;
 
171
 
 
172
-- echo ###################### TEST #7
 
173
 
 
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.
 
177
 
 
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
 
183
 
 
184
-- echo # assert: must show 1 entry
 
185
SELECT count(*) FROM t4;
 
186
 
 
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)
 
191
 
 
192
# 53 is the size of the incident event, so we start from 22 bytes before the
 
193
# current position
 
194
-- let $binlog_start = `SELECT $binlog_start - 53`
 
195
FLUSH LOGS;
 
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
 
199
 
 
200
# clean up and move to next test
 
201
DELETE FROM t4;
 
202
RESET MASTER;
 
203
 
 
204
-- echo ###################### TEST #8
 
205
 
 
206
### ASSERTION: check that statements end up in error but they succeed
 
207
###            on changing the data. 
 
208
 
 
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;
 
213
 
 
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');
 
222
 
 
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;
 
228
 
 
229
-- error ER_NO_UNIQUE_LOGFILE
 
230
DELETE FROM t4;
 
231
-- error ER_NO_UNIQUE_LOGFILE
 
232
DELETE FROM t2;
 
233
 
 
234
-- echo # INFO: Count(*) After Offending DELETEs
 
235
-- echo # assert: must show zero entries
 
236
SELECT count(*) FROM t4;
 
237
SELECT count(*) FROM t2;
 
238
 
 
239
# remove fault injection
 
240
SET GLOBAL debug="-d,error_unique_log_filename";
 
241
 
 
242
-- echo ###################### TEST #9
 
243
 
 
244
### ASSERTION: check that if we disable binlogging, then statements
 
245
###            succeed.
 
246
SET GLOBAL debug="+d,error_unique_log_filename";
 
247
SET SQL_LOG_BIN=0;
 
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;
 
253
DELETE FROM t2;
 
254
DELETE FROM t4;
 
255
-- echo # assert: must show zero entries
 
256
SELECT count(*) FROM t2;
 
257
SELECT count(*) FROM t4;
 
258
SET SQL_LOG_BIN=1;
 
259
SET GLOBAL debug="-d,error_unique_log_filename";
 
260
 
 
261
-- echo ###################### TEST #10
 
262
 
 
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.
 
266
 
 
267
call mtr.add_suppression("MSYQL_BIN_LOG::open failed to sync the index file.");
 
268
call mtr.add_suppression("Could not open .*");
 
269
 
 
270
RESET MASTER;
 
271
SHOW WARNINGS;
 
272
 
 
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
 
277
FLUSH LOGS;
 
278
SET GLOBAL debug="-d,fault_injection_registering_index";
 
279
 
 
280
-- error ER_NO_BINARY_LOGGING
 
281
SHOW BINARY LOGS;
 
282
 
 
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');
 
287
DELETE FROM t4;
 
288
DELETE FROM t2;
 
289
DROP TABLE t5;
 
290
 
 
291
-- echo ###################### TEST #11
 
292
 
 
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.
 
296
 
 
297
# restart the server so that we have binlog again
 
298
--let $rpl_server_number= 1
 
299
--source include/rpl_restart_server.inc
 
300
 
 
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
 
305
FLUSH LOGS;
 
306
SET GLOBAL debug="-d,fault_injection_openning_index";
 
307
 
 
308
-- error ER_FLUSH_MASTER_BINLOG_CLOSED
 
309
RESET MASTER;
 
310
 
 
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');
 
315
DELETE FROM t4;
 
316
DELETE FROM t2;
 
317
DROP TABLE t5;
 
318
 
 
319
# restart the server so that we have binlog again
 
320
--let $rpl_server_number= 1
 
321
--source include/rpl_restart_server.inc
 
322
 
 
323
-- echo ###################### TEST #12
 
324
 
 
325
### ASSERTION: check that error is reported if there is a failure
 
326
###            while writing the rotate event when creating a new log
 
327
###            file.
 
328
 
 
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
 
332
FLUSH LOGS;
 
333
SET GLOBAL debug="-d,fault_injection_new_file_rotate_event";
 
334
 
 
335
-- error ER_FLUSH_MASTER_BINLOG_CLOSED
 
336
RESET MASTER;
 
337
 
 
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');
 
342
DELETE FROM t4;
 
343
DELETE FROM t2;
 
344
DROP TABLE t5;
 
345
 
 
346
# restart the server so that we have binlog again
 
347
--let $rpl_server_number= 1
 
348
--source include/rpl_restart_server.inc
 
349
 
 
350
## clean up
 
351
SET GLOBAL debug= @old_debug;
 
352
DROP TABLE t1, t2, t4;
 
353
RESET MASTER;
 
354
 
 
355
# restart slave again
 
356
-- connection slave
 
357
-- source include/start_slave.inc
 
358
-- connection master
 
359
 
 
360
-- echo #######################################################################
 
361
-- echo ####################### PART 2: SLAVE TESTS ###########################
 
362
-- echo #######################################################################
 
363
 
 
364
### setup
 
365
--source include/rpl_reset.inc
 
366
-- connection slave
 
367
 
 
368
# slave suppressions
 
369
 
 
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
 
376
 
 
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
 
382
 
 
383
-- echo ###################### TEST #14
 
384
 
 
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
 
390
 
 
391
-- echo ###################### TEST #15
 
392
 
 
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
 
398
 
 
399
-- echo ###################### TEST #16
 
400
 
 
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
 
406
 
 
407
### clean up
 
408
-- source include/stop_slave_sql.inc
 
409
SET GLOBAL debug=@old_debug;
 
410
RESET SLAVE;
 
411
RESET MASTER;
 
412
--let $rpl_only_running_threads= 1
 
413
--source include/rpl_end.inc