Debian Codegraph @

mysql-test/suite/innodb/t/group_commit_binlog_pos.test

raw
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 EXECUTE 3";
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 send INSERT INTO t1 VALUES (2);
52
53 connection con3;
54 SET DEBUG_SYNC= "now WAIT_FOR con2_queued";
55 SET DEBUG_SYNC= "commit_after_prepare_ordered SIGNAL con3_queued";
56 send INSERT INTO t1 VALUES (3);
57
58 connection default;
59 SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
60 # At this point, no transactions are committed.
61 SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
62 SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
63 # At this point, 1 transaction is committed.
64 SET DEBUG_SYNC= "now SIGNAL con1_loop_cont";
65 SET DEBUG_SYNC= "now WAIT_FOR con1_loop";
66
67 # At this point, 2 transactions are committed.
68 SELECT * FROM t1 ORDER BY a;
69
70 connection con2;
71 reap;
72
73 # Now crash the server with 1+2 in-memory committed, 3 only prepared.
74 connection default;
75 system echo wait-group_commit_binlog_pos.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
76 SET SESSION debug_dbug="+d,crash_dispatch_command_before";
77 --error 2006,2013
78 SELECT 1;
79
80 connection con1;
81 --error 2006,2013
82 reap;
83 connection con3;
84 --error 2006,2013
85 reap;
86
87 system echo restart-group_commit_binlog_pos.test >> $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
88
89 connection default;
90 --enable_reconnect
91 --source include/wait_until_connected_again.inc
92
93 # Crash recovery should recover all three transactions.
94 SELECT * FROM t1 ORDER BY a;
95
96 # Check that the binlog position reported by InnoDB is the correct one
97 # for the end of the second transaction (as can be checked with
98 # mysqlbinlog).
99 let $MYSQLD_DATADIR= `SELECT @@datadir`;
100 # GTID thread_id increased the event size by 2*(1+4)
101 let pos=`select $binlog_start_pos + 739 + 2*(1+4)`;
102 --replace_result $pos <pos>
103 --exec sed -ne 's/.*\(InnoDB: Last binlog file .* position.*\)/\1/p' $MYSQLD_DATADIR/../../log/mysqld.1.err | tail -1
104
105 SET DEBUG_SYNC= 'RESET';
106 DROP TABLE t1;