| 1 |
# |
| 2 |
# WL#5493 & WL#5440 |
| 3 |
# Test case1 verifies if the transaction statements will not be |
| 4 |
# binlogged and replication will work fine, but the data will |
| 5 |
# be rolled back on master after the master restarts when setting |
| 6 |
# DEBUG POINT before binlog to make the master crash. |
| 7 |
# |
| 8 |
# Test case2 verifies if the transaction statements will be |
| 9 |
# binlogged and replication will work fine, and the data will |
| 10 |
# be recovered after the master restarts when setting DEBUG |
| 11 |
# POINT after binlog, and before the date is committed to make |
| 12 |
# the master crash. |
| 13 |
# |
| 14 |
# Test case3 verifies if the halfly binlogged transaction |
| 15 |
# statements will be trimmed from the crashed binlog file |
| 16 |
# and the data will not be recovered successfully after |
| 17 |
# the master restarts when setting DEBUG POINT in the |
| 18 |
# middle of binlog to make the master crash |
| 19 |
# |
| 20 |
# Test case4 verifies if the halfly binlogged non-transaction |
| 21 |
# statement will be trimmed from the crashed binlog file |
| 22 |
# and the data will not be recovered successfully after |
| 23 |
# the master restarts when setting DEBUG POINT in the |
| 24 |
# middle of binlog to make the master crash. |
| 25 |
# |
| 26 |
|
| 27 |
-- source include/not_group_replication_plugin.inc |
| 28 |
-- source include/not_rpl_gtid_only.inc |
| 29 |
# Don't test this under valgrind, memory leaks will occur |
| 30 |
-- source include/not_valgrind.inc |
| 31 |
-- source include/have_debug.inc |
| 32 |
-- source include/have_binlog_format_row.inc |
| 33 |
-- source include/not_crashrep.inc |
| 34 |
-- source include/not_have_privilege_checks_user.inc |
| 35 |
-- source include/master-slave.inc |
| 36 |
|
| 37 |
# Reset master |
| 38 |
connection slave; |
| 39 |
--source include/stop_slave.inc |
| 40 |
|
| 41 |
connection master; |
| 42 |
RESET MASTER; |
| 43 |
|
| 44 |
connection slave; |
| 45 |
--source include/start_slave.inc |
| 46 |
|
| 47 |
connection master; |
| 48 |
call mtr.add_suppression("Attempting backtrace"); |
| 49 |
call mtr.add_suppression("allocated tablespace *., old maximum was 0"); |
| 50 |
call mtr.add_suppression("Error in Log_event::read_log_event()"); |
| 51 |
call mtr.add_suppression("Buffered warning: Performance schema disabled"); |
| 52 |
|
| 53 |
-- let $old_debug = `select @@global.debug` |
| 54 |
-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 55 |
-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 56 |
CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB; |
| 57 |
|
| 58 |
-- echo # Test case1: Set DEBUG POINT before binlog to make |
| 59 |
-- echo # the master crash for transaction |
| 60 |
|
| 61 |
-- echo # Lets stop the slave IO thread first, so that it does not timeout on |
| 62 |
-- echo # reconnection while the master is down (it happened before on some |
| 63 |
-- echo # slow hosts). |
| 64 |
--source include/sync_slave_sql_with_master.inc |
| 65 |
--source include/stop_slave_io.inc |
| 66 |
--connection master |
| 67 |
|
| 68 |
BEGIN; |
| 69 |
let $rows= 3; |
| 70 |
WHILE($rows) |
| 71 |
{ |
| 72 |
INSERT INTO t1 (a) VALUES (REPEAT('a',2)); |
| 73 |
dec $rows; |
| 74 |
} |
| 75 |
# Write file to make mysql-test-run.pl expect crash and restart |
| 76 |
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 77 |
--disable_query_log |
| 78 |
eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,crash_commit_after_prepare"); |
| 79 |
--enable_query_log |
| 80 |
# Run the crashing query |
| 81 |
-- error 2013 |
| 82 |
COMMIT; |
| 83 |
|
| 84 |
-- source include/wait_until_disconnected.inc |
| 85 |
-- enable_reconnect |
| 86 |
-- echo # Restart the master server |
| 87 |
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 88 |
-- source include/wait_until_connected_again.inc |
| 89 |
-- disable_reconnect |
| 90 |
|
| 91 |
-- echo # Test the transaction statements will not be binlogged |
| 92 |
-- source include/show_binlog_events.inc |
| 93 |
|
| 94 |
--let $assert_cond= `SELECT COUNT(*) = 0 FROM t1` |
| 95 |
--let $assert_text= On master, test the data will be rolled back after restart. |
| 96 |
--source include/assert.inc |
| 97 |
|
| 98 |
--connection slave |
| 99 |
--echo # lets restart the slave io thread and check that |
| 100 |
--echo # the slave gets synchronized again |
| 101 |
--source include/start_slave_io.inc |
| 102 |
--connection master |
| 103 |
|
| 104 |
--source include/sync_slave_sql_with_master.inc |
| 105 |
-- echo # On slave, test replication will work fine, and the data |
| 106 |
-- echo # is not replicated |
| 107 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 108 |
--source include/diff_tables.inc |
| 109 |
|
| 110 |
connection master; |
| 111 |
-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 112 |
-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 113 |
-- echo # Test case2: Set DEBUG POINT after binlog, and before the date |
| 114 |
-- echo # is committed to make crash for transaction |
| 115 |
|
| 116 |
-- echo # Lets stop the slave IO thread first, so that it does not timeout on |
| 117 |
-- echo # reconnection while the master is down (it happened before on some |
| 118 |
-- echo # slow hosts). |
| 119 |
--source include/sync_slave_sql_with_master.inc |
| 120 |
--source include/stop_slave_io.inc |
| 121 |
--connection master |
| 122 |
|
| 123 |
BEGIN; |
| 124 |
let $rows= 3; |
| 125 |
WHILE($rows) |
| 126 |
{ |
| 127 |
INSERT INTO t1 (a) VALUES (REPEAT('a',2)); |
| 128 |
dec $rows; |
| 129 |
} |
| 130 |
# Write file to make mysql-test-run.pl expect crash and restart |
| 131 |
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 132 |
--disable_query_log |
| 133 |
eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,crash_commit_after_log"); |
| 134 |
--enable_query_log |
| 135 |
# Run the crashing query |
| 136 |
-- error 2013 |
| 137 |
COMMIT; |
| 138 |
|
| 139 |
-- source include/wait_until_disconnected.inc |
| 140 |
-- enable_reconnect |
| 141 |
-- echo # Restart the master server |
| 142 |
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 143 |
-- source include/wait_until_connected_again.inc |
| 144 |
-- disable_reconnect |
| 145 |
|
| 146 |
-- echo # Test the transaction statements will be binlogged |
| 147 |
-- source include/show_binlog_events.inc |
| 148 |
|
| 149 |
--let $assert_cond= `SELECT COUNT(*) = 3 FROM t1` |
| 150 |
--let $assert_text= On master, test the data will be recovered after the master restart. |
| 151 |
--source include/assert.inc |
| 152 |
|
| 153 |
--connection slave |
| 154 |
--echo # lets restart the slave io thread and check that |
| 155 |
--echo # the slave gets synchronized again |
| 156 |
--source include/start_slave_io.inc |
| 157 |
--connection master |
| 158 |
|
| 159 |
--source include/sync_slave_sql_with_master.inc |
| 160 |
-- echo # On slave, test replication will work fine, and the data is replicated |
| 161 |
--let $diff_tables= master:test.t1, slave:test.t1 |
| 162 |
--source include/diff_tables.inc |
| 163 |
|
| 164 |
connection master; |
| 165 |
DROP TABLE t1; |
| 166 |
--source include/sync_slave_sql_with_master.inc |
| 167 |
-- source include/stop_slave.inc |
| 168 |
|
| 169 |
connection master; |
| 170 |
-- let $binlog_start= query_get_value(SHOW MASTER STATUS, Position, 1) |
| 171 |
-- let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 172 |
# Test transaction with large data inserted |
| 173 |
CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB; |
| 174 |
|
| 175 |
-- echo # Test case3: Set DEBUG POINT in the middle of binlog to |
| 176 |
-- echo # make the master crash for transaction. |
| 177 |
BEGIN; |
| 178 |
let $rows= 24; |
| 179 |
WHILE($rows) |
| 180 |
{ |
| 181 |
INSERT INTO t1 (a) VALUES (REPEAT('a',6144)); |
| 182 |
dec $rows; |
| 183 |
} |
| 184 |
# Write file to make mysql-test-run.pl expect crash and restart |
| 185 |
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 186 |
--disable_query_log |
| 187 |
eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,half_binlogged_transaction"); |
| 188 |
--enable_query_log |
| 189 |
# Run the crashing query |
| 190 |
-- error 2013 |
| 191 |
COMMIT; |
| 192 |
|
| 193 |
-- source include/wait_until_disconnected.inc |
| 194 |
-- enable_reconnect |
| 195 |
-- echo # Restart the master server |
| 196 |
-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 197 |
-- source include/wait_until_connected_again.inc |
| 198 |
-- disable_reconnect |
| 199 |
|
| 200 |
-- echo # Test the halfly binlogged transaction will be trimmed |
| 201 |
-- echo # from the crashed binlog file |
| 202 |
-- source include/show_binlog_events.inc |
| 203 |
|
| 204 |
-- echo # Test the data will not be recovered successfully |
| 205 |
-- echo # after the master restart. |
| 206 |
SELECT COUNT(*) FROM t1; |
| 207 |
|
| 208 |
DROP TABLE t1; |
| 209 |
connection slave; |
| 210 |
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 0; |