~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_bug26395.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
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.
 
6
#
 
7
# This test was previously part of rpl_ndb_transaction.test
 
8
#
 
9
#
 
10
# ==== Method ====
 
11
#
 
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'
 
18
#
 
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.
 
23
#
 
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.
 
29
#
 
30
#
 
31
# ==== Related bugs ====
 
32
#
 
33
# BUG#26395: if crash during autocommit update to transactional table on master, slave fails
 
34
 
 
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;
 
39
 
 
40
 
 
41
--echo ==== Initialize ====
 
42
 
 
43
--echo [on master]
 
44
--connection master
 
45
 
 
46
CREATE TABLE tinnodb (a INT) ENGINE = INNODB;
 
47
SHOW CREATE TABLE tinnodb;
 
48
 
 
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';
 
52
 
 
53
 
 
54
--echo ==== Test ====
 
55
 
 
56
# Save the position up to which the slave SQL thread should execute.
 
57
save_master_pos;
 
58
 
 
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;
 
62
 
 
63
# Sync slave's IO thread.
 
64
--echo [on slave]
 
65
source include/sync_slave_io_with_master.inc;
 
66
 
 
67
# Sync slave's SQL thread.
 
68
sync_with_master 0;
 
69
 
 
70
 
 
71
--echo ==== Verify results on slave ====
 
72
 
 
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;
 
81
 
 
82
 
 
83
--echo ==== Clean up ====
 
84
 
 
85
# Easiest to clean up master and slave separately, without
 
86
# replication, since master and slave are out of sync.
 
87
 
 
88
--echo [on master]
 
89
connection master;
 
90
DROP TABLE tinnodb;
 
91
set @@debug= @old_debug;
 
92
 
 
93
--echo [on slave]
 
94
connection slave;
 
95
DROP TABLE tinnodb;
 
96
 
 
97
# Warning: do not add more tests here. The binlog is in a bad state.