Debian Codegraph @

mysql-test/suite/binlog/t/binlog_mdev342.test

raw
1 --source include/have_innodb.inc
2 --source include/have_debug.inc
3 --source include/have_debug_sync.inc
4 --source include/have_binlog_format_row.inc
5 # Valgrind does not work well with test that crashes the server
6 --source include/not_valgrind.inc
7
8 # (We do not need to restore these settings, as we crash the server).
9 SET GLOBAL max_binlog_size= 4096;
10 SET GLOBAL innodb_flush_log_at_trx_commit= 1;
11 RESET MASTER;
12
13 CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
14 # MDEV-515 takes X-lock on the table for the first insert
15 # In that case, Concurrent DML will get blocked
16 INSERT INTO t1 VALUES(100, "MDEV-515");
17 # One connection does an insert that causes a binlog rotate.
18 # The rotate is paused after writing new file but before updating index.
19 connect(con1,localhost,root,,);
20 SET DEBUG_SYNC= "binlog_open_before_update_index SIGNAL con1_ready WAIT_FOR con1_cont";
21 SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
22 send INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
23
24 connection default;
25 SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
26
27 # Another connection creates a prepared transaction.
28 # After the transaction is prepared, it will hang waiting for LOCK_log.
29 connect(con2,localhost,root,,);
30 SET DEBUG_SYNC= "ha_commit_trans_after_prepare SIGNAL con2_ready";
31 send INSERT INTO t1 VALUES (2, NULL);
32
33 connection default;
34 SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
35
36 # Now crash the server in con1, with old binlog closed, new binlog not yet in
37 # index, and one transaction in prepared-but-not-committed state.
38 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
39 wait-binlog_mdev342.test
40 EOF
41 # If con1 manages to race ahead and crash, we can see the crash already in the
42 # SET DEBUG_SYNC statement, so need --error here also.
43 --error 0,2006,2013
44 SET DEBUG_SYNC= "now SIGNAL con1_cont";
45 connection con1;
46 --error 2006,2013
47 reap;
48
49 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
50 restart-binlog_mdev342.test
51 EOF
52
53 connection default;
54 --enable_reconnect
55 --source include/wait_until_connected_again.inc
56
57 # Check that all transactions are recovered.
58 SELECT a FROM t1 ORDER BY a;
59
60 --source include/show_binary_logs.inc
61 --let $binlog_file= master-bin.000001
62 --let $binlog_start= 4
63 --source include/show_binlog_events.inc
64
65 # Cleanup
66 connection default;
67 DROP TABLE t1;