Debian Codegraph @

mysql-test/suite/rpl/t/rpl_xa_survive_crash_debug.test

raw
1 # The test verifies that crashed in the middle of XA COMMIT server
2 # does not lose the prepared transaction, neither it gets committed.
3 # This is to test that fixes to BUG #12161 Xa recovery and client disconnection
4 # do not break existing policy.
5 # The prepared XA can be identified and concluded with XA COMMIT or ROLLBACK,
6 # "manually" by the user.
7
8 --source include/not_valgrind.inc # Test takes too much time in Valgrind
9 --source include/have_debug.inc
10 # There's some format specifics through show_binlog_events,
11 # but MIXED is chosen rather to optimize.
12 --source include/have_binlog_format_mixed.inc
13 --source include/linux.inc
14
15 #
16 # Crash-safe testing is difficult on other than Linux.
17 # TODO: Open it back at XA-commit/rollback crash-safe bug/FR fixing.
18 #
19 --source include/master-slave.inc
20
21 --source include/rpl_connection_slave.inc
22 --source include/stop_slave.inc
23
24 --source include/rpl_connection_master.inc
25
26 call mtr.add_suppression("Found 1 prepared XA transactions");
27
28 CREATE TABLE t1 (a INT);
29
30 # Transaction is committed (XA-rollback) only
31 # to binlog, not to engine.
32 XA START 'xid_partly_rolled_back';
33 INSERT INTO t1 VALUES(1);
34 XA END 'xid_partly_rolled_back';
35 XA PREPARE 'xid_partly_rolled_back';
36
37 # Server crashes after doing the rollback, with Innodb engine
38 # rollback invoking first. XA ROLLBACK query is binlogged afterward.
39 # Yet the innodb tranasction has a good chance to remain in
40 # the engine after the master server restart which produces
41 # desired scenario: the query is logged, but the engine did not necessarily
42 # roll back.
43 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
44 SET @@session.debug="+d,crash_after_xa_rollback";
45 # CR_SERVER_LOST
46 --error 2013
47 XA ROLLBACK 'xid_partly_rolled_back';
48
49 #
50 # Server restart
51 #
52 --enable_reconnect
53 --source include/wait_until_disconnected.inc
54 --let $rpl_server_number= 1
55 --source include/rpl_start_server.inc
56 --disable_reconnect
57
58 --source include/rpl_connection_master.inc
59
60 # Due to non-determinism mentioned in the simulation part above
61 # the following query is commented out.
62 # Correct rollback handlerton ordering and thus deterministic behaviour
63 # is scheduled for bug#20672719 fixing (TODO: uncomment)
64
65 # XA RECOVER;
66
67 --let $assert_text = Zero records in t1 is expected at master
68 --let $assert_cond = COUNT(*) = 0 FROM t1
69 --source include/assert.inc
70 --source include/show_binlog_events.inc
71 SET @save.sql_log_bin = @@session.sql_log_bin;
72 SET @@session.sql_log_bin = 0;
73
74 #
75 # Rollback
76 # TODO: same as above, remove 0.
77 --error 0,ER_XAER_NOTA
78 XA ROLLBACK 'xid_partly_rolled_back';
79
80 SET @@session.sql_log_bin = @save.sql_log_bin;
81
82
83 --source include/rpl_connection_slave.inc
84 --source include/start_slave.inc
85
86 # Verify that slave has 'xid_partly_rolled_back' rolled back.
87
88 --source include/rpl_connection_master.inc
89 --source include/sync_slave_sql_with_master.inc
90 --let $assert_text = Zero records in t1 is expected at slave
91 --let $assert_cond = COUNT(*) = 0 FROM t1
92 --source include/assert.inc
93
94 #
95 # Cleanup
96 #
97 --source include/rpl_connection_master.inc
98
99 DROP TABLE t1;
100 --source include/sync_slave_sql_with_master.inc
101
102 --source include/rpl_end.inc