| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug_sync.inc |
| 3 |
--source include/have_log_bin.inc |
| 4 |
--source include/have_binlog_format_mixed_or_statement.inc |
| 5 |
--source include/binlog_start_pos.inc |
| 6 |
|
| 7 |
# Need DBUG to crash the server intentionally |
| 8 |
--source include/have_debug.inc |
| 9 |
# Don't test this under valgrind, memory leaks will occur as we crash |
| 10 |
--source include/not_valgrind.inc |
| 11 |
|
| 12 |
# The test case currently uses sed and tail, which may be unavailable on |
| 13 |
# some windows systems. But see MWL#191 for how to remove the need for grep. |
| 14 |
--source include/not_windows.inc |
| 15 |
|
| 16 |
# XtraDB stores the binlog position corresponding to the last commit, and |
| 17 |
# prints it during crash recovery. |
| 18 |
# Test that we get the correct position when we group commit several |
| 19 |
# transactions together. |
| 20 |
|
| 21 |
# What we really want to test here is what happens when a group of |
| 22 |
# transactions get written only partially to disk inside InnoDB before |
| 23 |
# the crash. But that is hard to test in mysql-test-run automated |
| 24 |
# tests. Instead, we use debug_sync to tightly control when each |
| 25 |
# transaction is written to the redo log. And we set |
| 26 |
# innodb_flush_log_at_trx_commit=3 so that we can write out |
| 27 |
# transactions individually - as with |
| 28 |
# innodb_flush_log_at_trx_commit=1, all commits are written together, |
| 29 |
# as part of a commit_checkpoint. |
| 30 |
# (Note that we do not have to restore innodb_flush_log_at_trx_commit, as |
| 31 |
# we crash the server). |
| 32 |
SET GLOBAL innodb_flush_log_at_trx_commit=3; |
| 33 |
|
| 34 |
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb; |
| 35 |
INSERT INTO t1 VALUES (0); |
| 36 |
|
| 37 |
connect(con1,localhost,root,,); |
| 38 |
connect(con2,localhost,root,,); |
| 39 |
connect(con3,localhost,root,,); |
| 40 |
|
| 41 |
# Queue up three commits for group commit. |
| 42 |
|
| 43 |
connection con1; |
| 44 |
SET DEBUG_SYNC= "commit_after_get_LOCK_log SIGNAL con1_waiting WAIT_FOR con3_queued"; |
| 45 |
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont"; |
| 46 |
send INSERT INTO t1 VALUES (1); |
| 47 |
|
| 48 |
connection con2; |
| 49 |
SET DEBUG_SYNC= "now WAIT_FOR con1_waiting"; |
| 50 |
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con2_queued"; |
| 51 |
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont"; |
| 52 |
send INSERT INTO t1 VALUES (2); |
| 53 |
|
| 54 |
connection con3; |
| 55 |
SET DEBUG_SYNC= "now WAIT_FOR con2_queued"; |
| 56 |
SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued"; |
| 57 |
SET DEBUG_SYNC= "commit_loop_entry_commit_ordered SIGNAL con1_loop WAIT_FOR con1_loop_cont"; |
| 58 |
send INSERT INTO t1 VALUES (3); |
| 59 |
|
| 60 |
connection default; |
| 61 |
SET DEBUG_SYNC= "now WAIT_FOR con1_loop"; |
| 62 |
# At this point, no transactions are committed. |
| 63 |
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont"; |
| 64 |
SET DEBUG_SYNC= "now WAIT_FOR con1_loop"; |
| 65 |
# At this point, 1 transaction is committed. |
| 66 |
SET DEBUG_SYNC= "now SIGNAL con1_loop_cont"; |
| 67 |
SET DEBUG_SYNC= "now WAIT_FOR con1_loop"; |
| 68 |
|
| 69 |
# At this point, 2 transactions are committed. |
| 70 |
SELECT * FROM t1 ORDER BY a; |
| 71 |
|
| 72 |
connection con1; |
| 73 |
reap; |
| 74 |
connection con2; |
| 75 |
reap; |
| 76 |
|
| 77 |
# Now crash the server with 1+2 in-memory committed, 3 only prepared. |
| 78 |
connection default; |
| 79 |
system echo wait-group_commit_binlog_pos_no_optimize_thread.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
| 80 |
SET SESSION debug_dbug="+d,crash_dispatch_command_before"; |
| 81 |
--error 2006,2013 |
| 82 |
SELECT 1; |
| 83 |
|
| 84 |
connection con3; |
| 85 |
--error 2006,2013 |
| 86 |
reap; |
| 87 |
|
| 88 |
system echo restart-group_commit_binlog_pos_no_optimize_thread.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect; |
| 89 |
|
| 90 |
connection default; |
| 91 |
--enable_reconnect |
| 92 |
--source include/wait_until_connected_again.inc |
| 93 |
|
| 94 |
# Crash recovery should recover all three transactions. |
| 95 |
SELECT * FROM t1 ORDER BY a; |
| 96 |
|
| 97 |
# Check that the binlog position reported by InnoDB is the correct one |
| 98 |
# for the end of the second transaction (as can be checked with |
| 99 |
# mysqlbinlog). |
| 100 |
let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 101 |
# GTID thread_id increased the event size by 2*(1+4) |
| 102 |
let pos=`select $binlog_start_pos + 739 + 2*(1+4)`; |
| 103 |
--replace_result $pos <pos> |
| 104 |
--exec sed -ne 's/.*\(InnoDB: Last binlog file .* position.*\)/\1/p' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1 |
| 105 |
SET DEBUG_SYNC= 'RESET'; |
| 106 |
DROP TABLE t1; |