mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 15:24:16 +01:00
123 lines
3.4 KiB
Text
123 lines
3.4 KiB
Text
# Tests that transactions are replicated correctly, with various
|
|
# combinations of non-transactional and transactional non-XA tables.
|
|
# Also tests that an XA transaction where the master crashes just
|
|
# before writing the XID log event is executed correctly. See below
|
|
# for implementation details.
|
|
|
|
source include/ndb_master-slave.inc;
|
|
source include/have_ndb.inc;
|
|
|
|
CREATE TABLE tmyisam (a int) ENGINE = MYISAM;
|
|
CREATE TABLE tinnodb (a int) ENGINE = INNODB;
|
|
CREATE TABLE tndb (a int) ENGINE = NDB;
|
|
|
|
SHOW CREATE TABLE tmyisam;
|
|
SHOW CREATE TABLE tinnodb;
|
|
SHOW CREATE TABLE tndb;
|
|
|
|
|
|
--echo ==== Test 1: Non-XA Engines ====
|
|
# Test that everything works fine with non-XA engines. We just try
|
|
# all ways to do transactions involving ndb and/or myisam, with
|
|
# rollback or commit.
|
|
|
|
--echo --- on master ---
|
|
|
|
SET AUTOCOMMIT = 1;
|
|
|
|
INSERT INTO tndb VALUES (1);
|
|
INSERT INTO tmyisam VALUES (1);
|
|
|
|
BEGIN;
|
|
INSERT INTO tndb VALUES (2);
|
|
INSERT INTO tndb VALUES (3);
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
INSERT INTO tmyisam VALUES (2);
|
|
INSERT INTO tmyisam VALUES (3);
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
INSERT INTO tndb VALUES (4);
|
|
INSERT INTO tmyisam VALUES (4);
|
|
COMMIT;
|
|
|
|
BEGIN;
|
|
INSERT INTO tndb VALUES (5);
|
|
INSERT INTO tndb VALUES (6);
|
|
ROLLBACK;
|
|
|
|
BEGIN;
|
|
INSERT INTO tmyisam VALUES (5);
|
|
INSERT INTO tmyisam VALUES (6);
|
|
--warning 1196
|
|
ROLLBACK;
|
|
|
|
BEGIN;
|
|
INSERT INTO tndb VALUES (7);
|
|
INSERT INTO tmyisam VALUES (7);
|
|
--warning 1196
|
|
ROLLBACK;
|
|
|
|
SELECT * FROM tndb ORDER BY a;
|
|
SELECT * FROM tmyisam ORDER BY a;
|
|
|
|
--echo --- on slave ---
|
|
--sync_slave_with_master
|
|
SELECT * FROM tndb ORDER BY a;
|
|
SELECT * FROM tmyisam ORDER BY a;
|
|
|
|
|
|
--echo ==== Test 2: Master crash before writing XID event on XA engine ====
|
|
# We now want to test the following scenario, to verify that BUG#26395
|
|
# has been fixed:
|
|
|
|
# "master and slave have a transactional table that uses XA. Master
|
|
# has AUTOCOMMIT on and executes a statement (in this case an
|
|
# INSERT). Master crashes just before writing the XID event."
|
|
|
|
# In this scenario, master will roll back, so slave should not execute
|
|
# the statement, and slave should roll back later when master is
|
|
# restarted.
|
|
|
|
# However, we the master to be alive so that we are sure it replicates
|
|
# the statement to the slave. So in the test case, we must therefore
|
|
# not crash the master. Instead, we fake the crash by just not writing
|
|
# the XID event to the binlog. This is done by the
|
|
# --debug=d,do_not_write_xid flag in the .opt file.
|
|
|
|
# So, unlike if the master had crashed, the master *will* execute the
|
|
# statement. But the slave should not execute it. Hence, after the
|
|
# first test is executed, the expected result on master is a table
|
|
# with one row, and on slave a table with no rows.
|
|
|
|
# To simulate the slave correctly, we wait until everything up to the
|
|
# XID is replicated. We cannot sync_slave_with_master, because that
|
|
# would wait for the transaction to end. Instead, we wait for
|
|
# "sufficiently long time". Then we stop the slave.
|
|
|
|
# Note: since this puts the master binlog in an inconsistent state,
|
|
# this should be the last test of the file.
|
|
|
|
--echo --- on master ---
|
|
--connection master
|
|
|
|
INSERT INTO tinnodb VALUES (1);
|
|
SELECT * FROM tinnodb ORDER BY a;
|
|
|
|
--echo --- on slave ---
|
|
--connection slave
|
|
--sleep 3
|
|
STOP SLAVE;
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
|
--replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
|
|
query_vertical SHOW SLAVE STATUS;
|
|
# the following statement should show that nothing has been replicated
|
|
SELECT * FROM tinnodb ORDER BY a;
|
|
|
|
|
|
# clean up
|
|
DROP TABLE tmyisam;
|
|
DROP TABLE tinnodb;
|
|
DROP TABLE tndb;
|