mariadb/mysql-test/suite/rpl/r/rpl_xa_empty_transaction.result
Brandon Nesterenko a061ae1079 MDEV-33921: Fix rpl_xa_empty_transaction.test
The test was missing a save_master_gtid.inc on the master,
leading to the slave thinking it was in sync after executing
sync_with_master_gtid.inc, despite not having executed the
latest transaction. This skipped transaction, XA COMMIT,
was supposed to error-to-be-ignored because its XID could not
be found, but be thrown out because the replication filters
would filter out the target database. However, if the slave
was able to stop before executing the transaction, then
the replication filer is reset (to empty), and when the
slave is later restarted, that transactions error would
no longer be ignored.

Additionally, as the test cases added in MDEV-33921 rely
on GTID synchronization, the test cases now force
master_use_gtid=slave_pos for consistency
2024-07-17 16:38:26 -06:00

1251 lines
40 KiB
Text

include/rpl_init.inc [topology=1->2->3]
connection server_1;
connection server_2;
connection server_3;
connection server_1;
#
# Test Case 1: An XA transaction without any statements should not be
# binlogged
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
#
# Test Case 2: An XA transaction consisting of a successfully rolled back
# statement should not be binlogged
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
#
# Test Case 3: An XA transaction with a statement that cannot be rolled
# back should be binlogged
connection server_1;
set @sav_binlog_format = @@binlog_format;
set @@binlog_format = row;
set @@global.binlog_format = row;
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
#
# Test Case 4: An XA transaction with multiple statements that can all
# be rolled back should not be binlogged
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
#
# Test Case 5: A mixed XA transaction consisting of one statement that
# can successfully be rolled back (first statement), and another that
# can not (second statement) should be binlogged
connection server_1;
set @sav_binlog_format = @@binlog_format;
set @@binlog_format = row;
set @@global.binlog_format = row;
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO ti VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
#
# Test Case 6: A mixed XA transaction consisting of one statement that
# cannot successfully be rolled back (first statement), and another that
# can (second statement) should be binlogged
connection server_1;
set @sav_binlog_format = @@binlog_format;
set @@binlog_format = row;
set @@global.binlog_format = row;
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO ti VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
#
# Test Case 7: An XA transaction consisting of two failed
# non-transactional statements should be binlogged
connection server_1;
set @sav_binlog_format = @@binlog_format;
set @@binlog_format = row;
set @@global.binlog_format = row;
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';;
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA COMMIT 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
XA ROLLBACK 'x';;
Warnings:
Warning 1196 Some non-transactional changed tables couldn't be rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connection server_2;
connection server_3;
connection server_1;
CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam;
CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
connect con1,localhost,root,,;
XA START 'x';
INSERT INTO tm VALUES (1),(1);;
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
INSERT INTO tm VALUES (2),(2);;
ERROR 23000: Duplicate entry '2' for key 'PRIMARY'
XA END 'x';
XA PREPARE 'x';
disconnect con1;
connection server_1;
XA RECOVER;
formatID gtrid_length bqual_length data
1 1 0 x
XA ROLLBACK 'x';;
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
include/save_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_1 should not binlog XA transaction]
connection server_2;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_2 should not binlog XA transaction]
connection server_3;
include/sync_with_master_gtid.inc
FLUSH LOGS;
# MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file
include/assert_grep.inc [server_3 should not binlog XA transaction]
connection server_1;
DROP TABLE ti,tm;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
connection server_1;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
#
# MDEV-33921.1: If a slave's replication of an XA transaction results in
# an empty transaction, e.g. due to replication filters, the slave
# should not binlog any part of the XA transaction.
connection server_1;
create database db1;
create database db2;
create table db1.t1 (a int) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
include/stop_slave.inc
change master to master_use_gtid=slave_pos;
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_ignore_db= "";
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
include/start_slave.inc
connection server_1;
use db1;
XA START "x1";
insert into db1.t1 values (1);
XA END "x1";
XA PREPARE "x1";
XA COMMIT "x1";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
connection server_2;
include/save_master_gtid.inc
connection server_3;
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# 33921.2: If the slave shuts down after "preparing" a filtered-to-empty
# XA transaction (and not completing it), then when the respective
# XA completion (COMMIT in this test) command is replicated, the slave
# should not throw ER_XAER_NOTA. Note that internally, the error is
# thrown, but it is ignored because the target db is filtered.
connection server_3;
include/stop_slave.inc
connection server_1;
use db1;
XA START "x2";
insert into db1.t1 values (2);
XA END "x2";
XA PREPARE "x2";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
# Connection named slave is needed for reconnection
connect slave,localhost,root,,;
connect slave1,localhost,root,,;
include/rpl_restart_server.inc [server_number=2]
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
include/start_slave.inc
connection server_1;
XA COMMIT "x2";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
include/save_master_gtid.inc
connection server_3;
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# 33921.3: Ensure XA commands are not considered by mysqlbinlog's
# --database filter
connection server_1;
# MYSQL_BINLOG datadir/binlog_file --start-position=pre_xa_pos --database=db2 --result-file=assert_file
include/assert_grep.inc [Mysqlbinlog should output all XA commands from the filtered transaction]
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_do_db="";
include/start_slave.inc
connection server_1;
drop database db1;
drop database db2;
connection server_1;
include/rpl_end.inc
# End of rpl_xa_empty_transaction.test