| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify that a transaction with wrong checksum is trimmed off from |
| 4 |
# the binary log when the server restarts and executes recovery. Such |
| 5 |
# recovery is executed if the server restarts after a crash. |
| 6 |
# |
| 7 |
# ==== Method ==== |
| 8 |
# |
| 9 |
# 1. Inject a wrong checksum using debug code. |
| 10 |
# 2. Crash server using debug_sync |
| 11 |
# 3. Restart server |
| 12 |
# 4. Show contents of binary log. |
| 13 |
# |
| 14 |
# ==== References ==== |
| 15 |
# |
| 16 |
# WL#5493 Binlog crash-safe when master crashed |
| 17 |
# WL#5440 Test binlog and replication when master crashed |
| 18 |
|
| 19 |
--let $old_debug = `select @@global.debug` |
| 20 |
--let $prefix = `select CONCAT(IF(LENGTH(@@global.debug) > 0, CONCAT(@@global.debug, ":"), ''), "d,debug,info,enter,return,query,")` |
| 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_binlog_format_row.inc |
| 25 |
-- source include/not_crashrep.inc |
| 26 |
|
| 27 |
call mtr.add_suppression("Attempting backtrace"); |
| 28 |
call mtr.add_suppression("allocated tablespace *., old maximum was 0"); |
| 29 |
call mtr.add_suppression("Error in Log_event::read_log_event()"); |
| 30 |
call mtr.add_suppression("Buffered warning: Performance schema disabled"); |
| 31 |
|
| 32 |
RESET MASTER; |
| 33 |
|
| 34 |
CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB; |
| 35 |
|
| 36 |
-- echo # Test case5: Inject wrong value of crc for a log event, and |
| 37 |
-- echo # then set DBUG POINT to casue the master crash. |
| 38 |
# Write file to make mysql-test-run.pl expect crash and restart |
| 39 |
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 40 |
-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 41 |
-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 42 |
|
| 43 |
BEGIN; |
| 44 |
INSERT INTO t1 (a) VALUES (REPEAT('a',1)); |
| 45 |
--disable_query_log |
| 46 |
eval SET SESSION debug=CONCAT('$prefix', "fault_injection_crc_value"); |
| 47 |
--enable_query_log |
| 48 |
INSERT INTO t1 (a) VALUES (REPEAT('a',2)); |
| 49 |
COMMIT; |
| 50 |
|
| 51 |
BEGIN; |
| 52 |
INSERT INTO t1 (a) VALUES (REPEAT('a',3)); |
| 53 |
--disable_query_log |
| 54 |
eval SET SESSION debug=CONCAT('$prefix', "crash_commit_after_prepare"); |
| 55 |
--enable_query_log |
| 56 |
# Run the crashing query |
| 57 |
-- error 2013 |
| 58 |
COMMIT; |
| 59 |
|
| 60 |
-- source include/wait_until_disconnected.inc |
| 61 |
-- enable_reconnect |
| 62 |
-- echo # Restart the master server |
| 63 |
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 64 |
-- source include/wait_until_connected_again.inc |
| 65 |
-- disable_reconnect |
| 66 |
|
| 67 |
-- echo # Test the transaction with a log event injected a wrong crc value |
| 68 |
-- echo # will be trimmed from the crashed binlog file |
| 69 |
-- source include/show_binlog_events.inc |
| 70 |
|
| 71 |
DROP TABLE t1; |
| 72 |
|