| 1 |
############################################################################### |
| 2 |
# Bug#11758766:MYSQLD CONTINUES OPERATION WITHOUT LOGGING WHEN BINLOGS |
| 3 |
# CANNOT BE WRITTEN |
| 4 |
# |
| 5 |
# Problem: |
| 6 |
# ======== |
| 7 |
# If an error occurs that prevents mysqld writing to the binary logs (disk |
| 8 |
# full, readonly filesystem, etc) then the logs are disabled and operations |
| 9 |
# continue. This can lead to out of sync slaves and improper backups. |
| 10 |
# |
| 11 |
# Test: |
| 12 |
# ===== |
| 13 |
# A new option "binlog_error_action" has been introduced whose values |
| 14 |
# are "IGNORE" or "ABORT". When binlogging becomes impossible if user sets |
| 15 |
# the variable to "ABORT" server will stop if user sets it to "IGNORE" binlog |
| 16 |
# will be turned off and server will continue. 4 different test cases are |
| 17 |
# added to check both the behaviours. |
| 18 |
############################################################################### |
| 19 |
--source include/have_log_bin.inc |
| 20 |
--source include/have_binlog_format_statement.inc |
| 21 |
# Don't test this under valgrind, memory leaks will occur |
| 22 |
--source include/not_valgrind.inc |
| 23 |
--source include/have_debug.inc |
| 24 |
--source include/have_debug_sync.inc |
| 25 |
# Avoid CrashReporter popup on Mac |
| 26 |
--source include/not_crashrep.inc |
| 27 |
|
| 28 |
call mtr.add_suppression("MYSQL_BIN_LOG::add_log_to_index failed to copy index file to crash safe index file."); |
| 29 |
call mtr.add_suppression("Disk is full writing *"); |
| 30 |
call mtr.add_suppression("Retry in 60 secs. *"); |
| 31 |
call mtr.add_suppression("Error writing file*"); |
| 32 |
call mtr.add_suppression("Could not open .*"); |
| 33 |
call mtr.add_suppression("Could not use .*"); |
| 34 |
call mtr.add_suppression("The server was unable to create a new log file *"); |
| 35 |
call mtr.add_suppression("An error occurred during flush stage of the commit"); |
| 36 |
call mtr.add_suppression("An error occurred during sync stage of the commit"); |
| 37 |
call mtr.add_suppression("Either disk is full or file system is read only"); |
| 38 |
call mtr.add_suppression("Can't open file:*"); |
| 39 |
call mtr.add_suppression("Can't generate a unique log-filename*"); |
| 40 |
call mtr.add_suppression("Attempting backtrace. You can use the following information to find out"); |
| 41 |
let $old=`select @@debug`; |
| 42 |
|
| 43 |
--let $saved_binlog_error_action=`SELECT @@GLOBAL.binlog_error_action` |
| 44 |
|
| 45 |
RESET MASTER; |
| 46 |
|
| 47 |
--echo Test case1 |
| 48 |
# Make binlog index readonly and check the behaviour with ABORT |
| 49 |
let $MYSQLD_DATADIR= `select @@datadir`; |
| 50 |
let $INDEX=$MYSQLD_DATADIR/binlog.index; |
| 51 |
--chmod 0444 $INDEX |
| 52 |
|
| 53 |
SET GLOBAL binlog_error_action= ABORT_SERVER; |
| 54 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 55 |
--replace_regex /\.[\\\/]binlog/binlog/ /errno: 1 - .*\)/errno: 1 - Operation not permitted)/ |
| 56 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 57 |
flush logs; |
| 58 |
--chmod 0666 $INDEX |
| 59 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 60 |
--enable_reconnect |
| 61 |
--source include/wait_until_connected_again.inc |
| 62 |
|
| 63 |
--echo Test case2 |
| 64 |
# Make MYSQL_BIN_LOG::open_binlog fail with debug simulation and test |
| 65 |
# the behaviour in case of ABORT |
| 66 |
SET SESSION debug="+d,fault_injection_updating_index"; |
| 67 |
SET GLOBAL binlog_error_action= ABORT_SERVER; |
| 68 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 69 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 70 |
flush logs; |
| 71 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 72 |
--enable_reconnect |
| 73 |
--source include/wait_until_connected_again.inc |
| 74 |
|
| 75 |
--echo Test case3 |
| 76 |
# Simulate diskfull during opening of binlog and check for diskfull error |
| 77 |
# behaviour where binlogging impossible error is to abort the server. |
| 78 |
SET SESSION debug="+d,simulate_disk_full_on_open_binlog"; |
| 79 |
SET GLOBAL binlog_error_action= ABORT_SERVER; |
| 80 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 81 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 82 |
flush logs; |
| 83 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 84 |
--enable_reconnect |
| 85 |
--source include/wait_until_connected_again.inc |
| 86 |
|
| 87 |
--echo Test case4 |
| 88 |
SET SESSION debug="+d,fault_injection_init_name"; |
| 89 |
SET GLOBAL binlog_error_action= ABORT_SERVER; |
| 90 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 91 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 92 |
flush logs; |
| 93 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 94 |
--enable_reconnect |
| 95 |
--source include/wait_until_connected_again.inc |
| 96 |
|
| 97 |
--echo Test case5 |
| 98 |
# Make binlog index readonly and check the behaviour with IGNORE |
| 99 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 100 |
--chmod 0444 $INDEX |
| 101 |
--replace_regex /\.[\\\/]binlog/binlog/ /errno: 13 - .*\)/errno: 13 - Permission denied)/ |
| 102 |
--error 29 |
| 103 |
flush logs; |
| 104 |
CREATE TABLE t1 ( f int ); |
| 105 |
SHOW TABLES; |
| 106 |
DROP TABLE t1; |
| 107 |
--chmod 0666 $INDEX |
| 108 |
--source include/restart_mysqld.inc |
| 109 |
|
| 110 |
--echo Test case6 |
| 111 |
# Make MYSQL_BIN_LOG::open_binlog fail with debug simulation and test |
| 112 |
# the behaviour in case of IGNORE |
| 113 |
SET SESSION debug="+d,fault_injection_updating_index"; |
| 114 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 115 |
--replace_regex /\.[\\\/]binlog/binlog/ /errno: 1 - .*\)/errno: 1 - Operation not permitted)/ |
| 116 |
--error ER_CANT_OPEN_FILE |
| 117 |
flush logs; |
| 118 |
CREATE TABLE t2 (f int ); |
| 119 |
SHOW TABLES; |
| 120 |
DROP TABLE t2; |
| 121 |
SET SESSION debug="-d,fault_injection_updating_index"; |
| 122 |
--source include/restart_mysqld.inc |
| 123 |
|
| 124 |
--echo Test case7 |
| 125 |
# Simulate diskfull during opening of binlog and check for diskfull error |
| 126 |
# behaviour where binlogging impossible error is to continue the server |
| 127 |
# after the error. |
| 128 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 129 |
SET SESSION debug="+d,simulate_disk_full_on_open_binlog"; |
| 130 |
--replace_regex /\.[\\\/]binlog/binlog/ /Errcode: 28 - .*\)/Errcode: 28 - No space left on device)/ |
| 131 |
# error EE_WRITE with error code number 3 is expected. |
| 132 |
--error 3 |
| 133 |
flush logs; |
| 134 |
SET SESSION debug="-d,simulate_disk_full_on_open_binlog"; |
| 135 |
--source include/restart_mysqld.inc |
| 136 |
|
| 137 |
--echo Test case8 |
| 138 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 139 |
SET SESSION debug="+d,fault_injection_init_name"; |
| 140 |
--replace_regex /\.[\\\/]binlog/binlog/ /errno: 1 - .*\)/errno: 1 - Operation not permitted)/ |
| 141 |
--error ER_CANT_OPEN_FILE |
| 142 |
flush logs; |
| 143 |
CREATE TABLE t2 (f int ); |
| 144 |
SHOW TABLES; |
| 145 |
DROP TABLE t2; |
| 146 |
SET SESSION debug="-d,fault_injection_init_name"; |
| 147 |
--source include/restart_mysqld.inc |
| 148 |
|
| 149 |
############################################################################### |
| 150 |
# Bug#20805298: BINLOG_ERROR_ACTION DOESN'T HANDLE SOME |
| 151 |
# FAILURES DURING BINLOG ROTATION |
| 152 |
# |
| 153 |
# Problem: |
| 154 |
# ======== |
| 155 |
# Hardware errors in binlog partition during binlog rotate are not handled by |
| 156 |
# binlog_error_action. |
| 157 |
# |
| 158 |
# Test: |
| 159 |
# ===== |
| 160 |
# Simulate failure during creation of new binary log file name. Set |
| 161 |
# binlog_error_action to "IGNORE_ERROR" and observe that the binary log gets |
| 162 |
# disabled and the server continues by logging an appropriate error message in |
| 163 |
# error log file. Set binlog_error_action to "ABORT_ERROR" and observe that |
| 164 |
# the |
| 165 |
# server aborts when creation of new binarylog file name fails. |
| 166 |
############################################################################### |
| 167 |
--echo Test case09 |
| 168 |
# Test error scenario with binlog_error_action=IGNORE_ERROR |
| 169 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 170 |
CREATE TABLE t1 (a INT) ENGINE=InnoDB; |
| 171 |
SET SESSION debug='+d,error_unique_log_filename'; |
| 172 |
--error ER_NO_UNIQUE_LOGFILE |
| 173 |
FLUSH LOGS; |
| 174 |
DROP TABLE t1; |
| 175 |
eval SET SESSION debug="$debug_save"; |
| 176 |
# Test to prove that binary log is disabled |
| 177 |
--error ER_NO_BINARY_LOGGING |
| 178 |
SHOW BINARY LOGS; |
| 179 |
--source include/restart_mysqld.inc |
| 180 |
|
| 181 |
--echo Test case10 |
| 182 |
# Test error scenario with binlog_error_action=ABORT_SERVER |
| 183 |
|
| 184 |
CREATE TABLE t1 (a INT) ENGINE=InnoDB; |
| 185 |
SET GLOBAL binlog_error_action=ABORT_SERVER; |
| 186 |
SET SESSION debug='+d,error_unique_log_filename'; |
| 187 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 188 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 189 |
FLUSH LOGS; |
| 190 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 191 |
--enable_reconnect |
| 192 |
--source include/wait_until_connected_again.inc |
| 193 |
DROP TABLE t1; |
| 194 |
|
| 195 |
############################################################################### |
| 196 |
# BUG#16666407BINLOG WRITE ERRORS SILENTLY IGNORED |
| 197 |
# BUG#20938915 2PC SUCCEEDS EVEN THOUGH BINLOG FLUSH/SYNC FAILS |
| 198 |
############################################################################### |
| 199 |
|
| 200 |
############################ |
| 201 |
--echo Test case11 |
| 202 |
############################ |
| 203 |
|
| 204 |
# Simulate error during flushing cache to file and test the behaviour |
| 205 |
# when binlog_error_action is set to ABORT_SERVER/IGNORE_ERROR. |
| 206 |
|
| 207 |
# Case 11.1 (binlog_error_action = ABORT_SERVER) |
| 208 |
--source include/shutdown_mysqld.inc |
| 209 |
--remove_file $MYSQLTEST_VARDIR/tmp/binlog_error_action.err |
| 210 |
--source include/start_mysqld.inc |
| 211 |
RESET MASTER; |
| 212 |
|
| 213 |
CREATE TABLE t1(i INT); |
| 214 |
--let $log_pos_before = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 215 |
SET SESSION debug = "+d,simulate_error_during_flush_cache_to_file"; |
| 216 |
SET GLOBAL binlog_error_action = ABORT_SERVER; |
| 217 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 218 |
|
| 219 |
# Check that flush error causing server to abort and client gets |
| 220 |
# ER_BINLOG_LOGGING_IMPOSSIBLE when binlog_error_action= 'ABORT_SERVER'. |
| 221 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 222 |
INSERT INTO t1 VALUES (1); |
| 223 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 224 |
--enable_reconnect |
| 225 |
--source include/wait_until_connected_again.inc |
| 226 |
|
| 227 |
# Check that error present in error log |
| 228 |
--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/binlog_error_action.err |
| 229 |
--let SEARCH_PATTERN = An error occurred during flush stage of the commit. 'binlog_error_action' is set to 'ABORT_SERVER'. |
| 230 |
--source include/search_pattern.inc |
| 231 |
|
| 232 |
# Check that transaction is not committed |
| 233 |
--let $assert_cond= COUNT(*) = 0 FROM t1; |
| 234 |
--let $assert_text= Count of elements in t1 should be 0. |
| 235 |
--source include/assert.inc |
| 236 |
|
| 237 |
# Check that transaction is not binlogged as well |
| 238 |
--let $log_pos_after = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 239 |
--let $assert_cond = $log_pos_before = $log_pos_after |
| 240 |
--let $assert_text = Query is not binlogged as expected. |
| 241 |
--source include/assert.inc |
| 242 |
|
| 243 |
# Case 11.2 (binlog_error_action = IGNORE_ERROR) |
| 244 |
RESET MASTER; |
| 245 |
--let $log_pos_before = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 246 |
SET SESSION debug ="+d,simulate_error_during_flush_cache_to_file"; |
| 247 |
SET GLOBAL binlog_error_action= IGNORE_ERROR; |
| 248 |
INSERT INTO t1 VALUES (2); |
| 249 |
|
| 250 |
# Check that transaction is committed |
| 251 |
--let $assert_cond = COUNT(*) = 1 FROM t1; |
| 252 |
--let $assert_text = Count of elements in t1 should be 1. |
| 253 |
--source include/assert.inc |
| 254 |
|
| 255 |
# Restart so that binary log is enabled again and we can do the below test |
| 256 |
--source include/restart_mysqld.inc |
| 257 |
|
| 258 |
# Check that transaction is not binlogged |
| 259 |
--let $log_pos_after = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 260 |
--let $assert_cond = $log_pos_before = $log_pos_after |
| 261 |
--let $assert_text = Query is not binlogged as expected. |
| 262 |
--source include/assert.inc |
| 263 |
|
| 264 |
# Check that error present in error log |
| 265 |
--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/binlog_error_action.err |
| 266 |
--let SEARCH_PATTERN = An error occurred during flush stage of the commit. 'binlog_error_action' is set to 'IGNORE_ERROR'. |
| 267 |
--source include/search_pattern.inc |
| 268 |
|
| 269 |
# Cleanup |
| 270 |
DROP TABLE t1; |
| 271 |
RESET MASTER; |
| 272 |
|
| 273 |
############################ |
| 274 |
--echo Test case12 |
| 275 |
############################ |
| 276 |
|
| 277 |
# Simulate error during syncing binlog file and test the behaviour |
| 278 |
# when binlog_error_action is set to ABORT_SERVER/IGNORE_ERROR. |
| 279 |
# Set sync_binlog=1 just to make sure that logic enters into sync phase. |
| 280 |
|
| 281 |
# Case 12.1 (binlog_error_action = ABORT_SERVER) |
| 282 |
SET GLOBAL sync_binlog = 1; |
| 283 |
CREATE TABLE t1(i INT); |
| 284 |
SET SESSION debug = "+d,simulate_error_during_sync_binlog_file"; |
| 285 |
SET GLOBAL binlog_error_action = ABORT_SERVER; |
| 286 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 287 |
|
| 288 |
# Check that sync error causing server to abort and client gets |
| 289 |
# ER_BINLOG_LOGGING_IMPOSSIBLE when binlog_error_action= 'ABORT_SERVER'. |
| 290 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 291 |
INSERT INTO t1 VALUES (1); |
| 292 |
|
| 293 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 294 |
--enable_reconnect |
| 295 |
--source include/wait_until_connected_again.inc |
| 296 |
|
| 297 |
# Cleanup |
| 298 |
DELETE FROM t1; |
| 299 |
RESET MASTER; |
| 300 |
|
| 301 |
# Case 12.2 (binlog_error_action = IGNORE_ERROR) |
| 302 |
SET SESSION debug = "+d,simulate_error_during_sync_binlog_file"; |
| 303 |
SET GLOBAL binlog_error_action = IGNORE_ERROR; |
| 304 |
INSERT INTO t1 VALUES (2); |
| 305 |
|
| 306 |
# Check that transaction is committed |
| 307 |
--let $assert_cond = COUNT(*) = 1 FROM t1; |
| 308 |
--let $assert_text = Count of elements in t1 should be 1. |
| 309 |
--source include/assert.inc |
| 310 |
|
| 311 |
# Cleanup |
| 312 |
DROP table t1; |
| 313 |
SET SESSION debug = "-d,simulate_error_during_sync_binlog_file"; |
| 314 |
--source include/restart_mysqld.inc |
| 315 |
RESET MASTER; |
| 316 |
|
| 317 |
############################ |
| 318 |
--echo Test case13 |
| 319 |
############################ |
| 320 |
|
| 321 |
# Simulate error during flushing events to binlog cache and test the behaviour |
| 322 |
# when binlog_error_action is set to ABORT_SERVER/IGNORE_ERROR. |
| 323 |
|
| 324 |
# Case 13.1 (binlog_error_action = ABORT_SERVER) |
| 325 |
CREATE TABLE t1(i INT); |
| 326 |
--let $log_pos_before = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 327 |
SET SESSION debug = "+d,simulate_do_write_cache_failure"; |
| 328 |
SET GLOBAL binlog_error_action = ABORT_SERVER; |
| 329 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 330 |
|
| 331 |
# Check that write cache error is causing server to abort and client gets |
| 332 |
# ER_BINLOG_LOGGING_IMPOSSIBLE when binlog_error_action= 'ABORT_SERVER'. |
| 333 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 334 |
INSERT INTO t1 VALUES (1); |
| 335 |
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 336 |
--enable_reconnect |
| 337 |
--source include/wait_until_connected_again.inc |
| 338 |
|
| 339 |
# Check that transaction is not committed |
| 340 |
--let $assert_cond = COUNT(*) = 0 FROM t1; |
| 341 |
--let $assert_text = Count of elements in t1 should be 0. |
| 342 |
--source include/assert.inc |
| 343 |
|
| 344 |
# Check that transaction is not binlogged as well |
| 345 |
--let $log_pos_after = query_get_value("SHOW BINARY LOGS", File_size, 1) |
| 346 |
--let $assert_cond = $log_pos_before = $log_pos_after |
| 347 |
--let $assert_text = Query is not binlogged as expected. |
| 348 |
--source include/assert.inc |
| 349 |
|
| 350 |
# Cleanup |
| 351 |
RESET MASTER; |
| 352 |
|
| 353 |
# Case 13.2 (binlog_error_action = IGNORE_ERROR) |
| 354 |
SET SESSION debug = "+d,simulate_do_write_cache_failure"; |
| 355 |
SET GLOBAL binlog_error_action = IGNORE_ERROR; |
| 356 |
INSERT INTO t1 VALUES (2); |
| 357 |
|
| 358 |
# Check that transaction is committed (binlog check cannot be done |
| 359 |
# as we would have written STOP_EVENT in the binlog while closing |
| 360 |
# it) |
| 361 |
--let $assert_cond = COUNT(*) = 1 FROM t1; |
| 362 |
--let $assert_text = Count of elements in t1 should be 1. |
| 363 |
--source include/assert.inc |
| 364 |
|
| 365 |
# Cleanup |
| 366 |
DROP table t1; |
| 367 |
--source include/restart_mysqld.inc |
| 368 |
RESET MASTER; |
| 369 |
|
| 370 |
############################ |
| 371 |
--echo Test case14 |
| 372 |
############################ |
| 373 |
|
| 374 |
# Simulating a situation when a transaction is about to |
| 375 |
# enter ordered_commit and another transaction closed |
| 376 |
# binary log due to an error. |
| 377 |
|
| 378 |
SET GLOBAL binlog_error_action = IGNORE_ERROR; |
| 379 |
SET GLOBAL sync_binlog = 1; |
| 380 |
CREATE TABLE t1(i INT); |
| 381 |
CREATE TABLE t2(i INT); |
| 382 |
connect(con1,localhost,root,,); |
| 383 |
connect(con2,localhost,root,,); |
| 384 |
|
| 385 |
--connection con1 |
| 386 |
SET DEBUG_SYNC = "bgc_before_flush_stage SIGNAL about_to_enter_flush_stage WAIT_FOR binlog_closed"; |
| 387 |
--send INSERT INTO t1 values (1); |
| 388 |
|
| 389 |
--connection default |
| 390 |
SET DEBUG_SYNC = "now wait_for about_to_enter_flush_stage"; |
| 391 |
|
| 392 |
--connection con2 |
| 393 |
SET DEBUG_SYNC = "after_binlog_closed_due_to_error SIGNAL binlog_closed"; |
| 394 |
SET SESSION debug = "+d,simulate_error_during_sync_binlog_file"; |
| 395 |
--send INSERT INTO t2 values (2); |
| 396 |
|
| 397 |
--connection con1 |
| 398 |
--reap |
| 399 |
--connection con2 |
| 400 |
--reap |
| 401 |
|
| 402 |
# Cleanup |
| 403 |
--disconnect con1 |
| 404 |
--disconnect con2 |
| 405 |
|
| 406 |
--connection default |
| 407 |
DROP table t1, t2; |
| 408 |
--source include/restart_mysqld.inc |
| 409 |
|
| 410 |
############################ |
| 411 |
--echo Test case15 |
| 412 |
############################ |
| 413 |
|
| 414 |
# Simulating a situation when a transaction is about to |
| 415 |
# close binary log due to a sync error (about to acquire lock_log) |
| 416 |
# and another transaction in the middle of flush stage (holding |
| 417 |
# lock_log. |
| 418 |
|
| 419 |
SET GLOBAL binlog_error_action = IGNORE_ERROR; |
| 420 |
SET GLOBAL sync_binlog = 1; |
| 421 |
CREATE TABLE t1(i INT); |
| 422 |
CREATE TABLE t2(i INT); |
| 423 |
connect(con1,localhost,root,,); |
| 424 |
connect(con2,localhost,root,,); |
| 425 |
|
| 426 |
--connection con1 |
| 427 |
SET DEBUG_SYNC = "before_binlog_closed_due_to_error SIGNAL binlog_about_to_be_closed WAIT_FOR in_the_middle_of_flush_stage"; |
| 428 |
SET SESSION debug = "+d,simulate_error_during_sync_binlog_file"; |
| 429 |
--send INSERT INTO t1 values (1); |
| 430 |
|
| 431 |
--connection default |
| 432 |
SET DEBUG_SYNC = "now wait_for binlog_about_to_be_closed"; |
| 433 |
|
| 434 |
--connection con2 |
| 435 |
SET DEBUG_SYNC = "waiting_in_the_middle_of_flush_stage SIGNAL in_the_middle_of_flush_stage"; |
| 436 |
--send INSERT INTO t2 values (2); |
| 437 |
|
| 438 |
--connection con1 |
| 439 |
--reap |
| 440 |
--connection con2 |
| 441 |
--reap |
| 442 |
|
| 443 |
# Claenup |
| 444 |
--disconnect con1 |
| 445 |
--disconnect con2 |
| 446 |
|
| 447 |
--connection default |
| 448 |
DROP table t1, t2; |
| 449 |
--source include/shutdown_mysqld.inc |
| 450 |
--remove_file $MYSQLTEST_VARDIR/tmp/binlog_error_action.err |
| 451 |
--source include/start_mysqld.inc |
| 452 |
|
| 453 |
############################ |
| 454 |
--echo Test case16 |
| 455 |
############################ |
| 456 |
|
| 457 |
# Simulating a situation where two binlog groups encounter |
| 458 |
# errors (one flush error, one sync error) at the same time |
| 459 |
# and both of them try to close the binary log. |
| 460 |
|
| 461 |
SET GLOBAL binlog_error_action = IGNORE_ERROR; |
| 462 |
SET GLOBAL sync_binlog = 1; |
| 463 |
CREATE TABLE t1(i INT); |
| 464 |
CREATE TABLE t2(i INT); |
| 465 |
connect(con1,localhost,root,,); |
| 466 |
connect(con2,localhost,root,,); |
| 467 |
|
| 468 |
--connection con1 |
| 469 |
SET DEBUG_SYNC = "before_binlog_closed_due_to_error SIGNAL binlog_about_to_be_closed WAIT_FOR another_group_encountered_flush_error"; |
| 470 |
SET SESSION debug = "+d,simulate_error_during_sync_binlog_file"; |
| 471 |
--send INSERT INTO t1 values (1); |
| 472 |
|
| 473 |
--connection default |
| 474 |
SET DEBUG_SYNC = "now wait_for binlog_about_to_be_closed"; |
| 475 |
|
| 476 |
--connection con2 |
| 477 |
SET DEBUG_SYNC = "before_binlog_closed_due_to_error SIGNAL another_group_encountered_flush_error"; |
| 478 |
SET SESSION debug ="+d,simulate_error_during_flush_cache_to_file"; |
| 479 |
--send INSERT INTO t2 values (2); |
| 480 |
|
| 481 |
--connection con1 |
| 482 |
--reap |
| 483 |
--connection con2 |
| 484 |
--reap |
| 485 |
--replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{6}[-+Z][0-9:]* *[0-9]*/--TIME--/ /flush|sync stage/flush_or_sync stage/ |
| 486 |
--let GREP_FILE=$MYSQLTEST_VARDIR/tmp/binlog_error_action.err |
| 487 |
--let GREP_PATTERN=An error occurred during |
| 488 |
--source include/grep_pattern.inc |
| 489 |
|
| 490 |
# Claenup |
| 491 |
--disconnect con1 |
| 492 |
--disconnect con2 |
| 493 |
|
| 494 |
--connection default |
| 495 |
DROP table t1, t2; |
| 496 |
--source include/restart_mysqld.inc |
| 497 |
|
| 498 |
############################ |
| 499 |
--echo Test case17 |
| 500 |
############################ |
| 501 |
|
| 502 |
# Failed to write a binlog encrypted header |
| 503 |
|
| 504 |
--let $keyring_data= $MYSQLTEST_VARDIR/tmp/keyring_data |
| 505 |
--source include/shutdown_mysqld.inc |
| 506 |
--let $restart_parameters=restart: $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_data --binlog_encryption=ON |
| 507 |
--replace_result $KEYRING_PLUGIN_OPT KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD KEYRING_PLUGIN_LOAD $keyring_data keyring_data |
| 508 |
--source include/start_mysqld.inc |
| 509 |
--let $debug_point=fail_to_serialize_encryption_header |
| 510 |
--source include/add_debug_point.inc |
| 511 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 512 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 513 |
FLUSH LOGS; |
| 514 |
--exec echo "$restart_parameters" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 515 |
--enable_reconnect |
| 516 |
--source include/wait_until_connected_again.inc |
| 517 |
SET @@GLOBAL.binlog_encryption=OFF; |
| 518 |
RESET MASTER; |
| 519 |
UNINSTALL PLUGIN keyring_file; |
| 520 |
--remove_file $keyring_data |
| 521 |
--let $restart_parameters= |
| 522 |
--source include/restart_mysqld.inc |
| 523 |
|
| 524 |
############################ |
| 525 |
--echo Test case18 |
| 526 |
############################ |
| 527 |
|
| 528 |
# Failed to generate new file password |
| 529 |
|
| 530 |
--let $keyring_data= $MYSQLTEST_VARDIR/tmp/keyring_data |
| 531 |
--source include/shutdown_mysqld.inc |
| 532 |
--let $restart_parameters=restart: $KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD --keyring_file_data=$keyring_data --binlog_encryption=ON |
| 533 |
--replace_result $KEYRING_PLUGIN_OPT KEYRING_PLUGIN_OPT $KEYRING_PLUGIN_LOAD KEYRING_PLUGIN_LOAD $keyring_data keyring_data |
| 534 |
--source include/start_mysqld.inc |
| 535 |
--let $debug_point=fail_to_generate_new_file_password |
| 536 |
--source include/add_debug_point.inc |
| 537 |
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 538 |
--error ER_BINLOG_LOGGING_IMPOSSIBLE |
| 539 |
FLUSH LOGS; |
| 540 |
--exec echo "$restart_parameters" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 541 |
--enable_reconnect |
| 542 |
--source include/wait_until_connected_again.inc |
| 543 |
SET @@GLOBAL.binlog_encryption=OFF; |
| 544 |
RESET MASTER; |
| 545 |
UNINSTALL PLUGIN keyring_file; |
| 546 |
--remove_file $keyring_data |
| 547 |
--let $restart_parameters= |
| 548 |
--source include/restart_mysqld.inc |