3
# Tests that an autocommitted XA transaction where the master crashes
4
# just before writing the XID log event is executed correctly. The
5
# master rolls back, so the slave should not execute statement.
7
# This test was previously part of rpl_ndb_transaction.test
12
# We want master to be alive so that it can replicate the statement to
13
# the slave. So in the test case, we must not crash the
14
# master. Instead, we fake the crash by just not writing the XID event
15
# to the binlog. This is done by the @@debug='d,do_not_write_xid'
16
# flag. This, in turn, requires us to do 'source
17
# include/have_debug.inc'
19
# So, unlike if the master had crashed, the master *will* execute the
20
# statement. But the slave should not execute it. Hence, after the
21
# test is executed, the expected result on master is a table with one
22
# row, and on slave a table with no rows.
24
# To simulate the slave correctly, we wait until everything up to but
25
# not including the XID is replicated. This has to be done with
26
# include/sync_slave_io_with_master.inc, not sync_slave_with_master,
27
# since the latter waits until the slave *SQL* thread has caught up
28
# with the master's position, which it will never do.
31
# ==== Related bugs ====
33
# BUG#26395: if crash during autocommit update to transactional table on master, slave fails
35
source include/have_innodb.inc;
36
# have_debug is needed since we use the @@debug variable on master
37
source include/have_debug.inc;
38
source include/master-slave.inc;
41
--echo ==== Initialize ====
46
CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
47
SHOW CREATE TABLE tinnodb;
49
# do_not_write_xid stops the master from writing an XID event.
50
set @old_debug= @@debug;
51
set @@debug= 'd,do_not_write_xid';
56
# Save the position up to which the slave SQL thread should execute.
59
# Execute query and check that the row made it to the table.
60
INSERT INTO tinnodb VALUES (1);
61
SELECT * FROM tinnodb ORDER BY a;
63
# Sync slave's IO thread.
65
source include/sync_slave_io_with_master.inc;
67
# Sync slave's SQL thread.
71
--echo ==== Verify results on slave ====
73
source include/stop_slave.inc;
74
let $tmp= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1);
75
eval SELECT "$tmp" AS Slave_IO_State;
76
let $tmp= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
77
eval SELECT "$tmp" AS Last_SQL_Error;
78
let $tmp= query_get_value("SHOW SLAVE STATUS", Last_IO_Error, 1);
79
eval SELECT "$tmp" AS Last_IO_Error;
80
SELECT * FROM tinnodb ORDER BY a;
83
--echo ==== Clean up ====
85
# Easiest to clean up master and slave separately, without
86
# replication, since master and slave are out of sync.
91
set @@debug= @old_debug;
97
# Warning: do not add more tests here. The binlog is in a bad state.