diff options
Diffstat (limited to 'mysql-test/suite')
-rw-r--r-- | mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result | 108 | ||||
-rw-r--r-- | mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test | 52 | ||||
-rw-r--r-- | mysql-test/suite/federated/federatedx_create_handlers.result | 49 | ||||
-rw-r--r-- | mysql-test/suite/federated/federatedx_create_handlers.test | 48 | ||||
-rw-r--r-- | mysql-test/suite/galera/disabled.def | 4 | ||||
-rw-r--r-- | mysql-test/suite/galera/r/galera_many_rows.result | 14 | ||||
-rw-r--r-- | mysql-test/suite/galera/t/galera_many_rows.test | 6 | ||||
-rw-r--r-- | mysql-test/suite/innodb/r/instant_alter.result | 11 | ||||
-rw-r--r-- | mysql-test/suite/innodb/t/instant_alter.test | 18 | ||||
-rw-r--r-- | mysql-test/suite/plugins/t/false_dupes-6543.test | 1 | ||||
-rw-r--r-- | mysql-test/suite/rpl/include/rpl_xa_empty_transaction.inc | 10 | ||||
-rw-r--r-- | mysql-test/suite/rpl/include/rpl_xa_empty_transaction_test_case.inc | 131 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_xa_empty_transaction.result | 1169 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_xa_empty_transaction.cnf | 18 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_xa_empty_transaction.test | 175 |
15 files changed, 1803 insertions, 11 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result b/mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result index 9f998e049c0..589570d8300 100644 --- a/mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result +++ b/mysql-test/suite/binlog/r/binlog_empty_xa_prepared.result @@ -108,3 +108,111 @@ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP SEQUENCE `s` /* generated by server */ master-bin.000001 # Gtid # # GTID #-#-# master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +connect con1,localhost,root,,; +XA START '1'; +INSERT INTO t1 VALUES (2),(1); +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT * FROM t1 WHERE a = 2; +a +XA END '1'; +XA PREPARE '1'; +disconnect con1; +connection default; +XA RECOVER; +formatID gtrid_length bqual_length data +1 1 0 1 +XA COMMIT '1'; +ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back +Must be no XA PREPARE group nor XA completion one: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE SEQUENCE s ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # SELECT NEXT VALUE FOR s +master-bin.000001 # Table_map # # table_id: # (test.s) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # XA START X'32',X'',1 GTID #-#-# +master-bin.000001 # Query # # XA END X'32',X'',1 +master-bin.000001 # XA_prepare # # XA PREPARE X'32',X'',1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # XA ROLLBACK X'32',X'',1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP SEQUENCE `s` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +DROP TABLE t1; +connect con2,localhost,root,,; +CREATE TABLE tm (a INT PRIMARY KEY) ENGINE=MyISAM; +XA START '1'; +INSERT INTO tm VALUES (1),(1); +ERROR 23000: Duplicate entry '1' for key 'PRIMARY' +SELECT * FROM tm WHERE a = 2; +a +XA END '1'; +XA PREPARE '1'; +disconnect con2; +connection default; +XA RECOVER; +formatID gtrid_length bqual_length data +1 1 0 1 +XA ROLLBACK '1'; +ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back +Must be no XA PREPARE group nor XA completion one: +include/show_binlog_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE SEQUENCE s ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # SELECT NEXT VALUE FOR s +master-bin.000001 # Table_map # # table_id: # (test.s) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Query # # COMMIT +master-bin.000001 # Gtid # # XA START X'32',X'',1 GTID #-#-# +master-bin.000001 # Query # # XA END X'32',X'',1 +master-bin.000001 # XA_prepare # # XA PREPARE X'32',X'',1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # XA ROLLBACK X'32',X'',1 +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP SEQUENCE `s` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Annotate_rows # # INSERT INTO t1 VALUES (1) +master-bin.000001 # Table_map # # table_id: # (test.t1) +master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F +master-bin.000001 # Xid # # COMMIT /* XID */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */ +master-bin.000001 # Gtid # # GTID #-#-# +master-bin.000001 # Query # # use `test`; CREATE TABLE tm (a INT PRIMARY KEY) ENGINE=MyISAM +master-bin.000001 # Gtid # # BEGIN GTID #-#-# +master-bin.000001 # Query # # use `test`; INSERT INTO tm VALUES (1),(1) +master-bin.000001 # Query # # COMMIT +DROP TABLE tm; diff --git a/mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test b/mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test index 443feb60627..2890c42a087 100644 --- a/mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test +++ b/mysql-test/suite/binlog/t/binlog_empty_xa_prepared.test @@ -80,3 +80,55 @@ DROP TABLE t1; --echo # Proof of correct logging incl empty XA-PREPARE --source include/show_binlog_events.inc + + +# MDEV-25616 Binlog event for XA COMMIT is generated without matching XA START + +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); + +--source include/count_sessions.inc +--connect(con1,localhost,root,,) + +XA START '1'; + --error ER_DUP_ENTRY + INSERT INTO t1 VALUES (2),(1); + SELECT * FROM t1 WHERE a = 2; +XA END '1'; +XA PREPARE '1'; + +--disconnect con1 + +--connection default +--source include/wait_until_count_sessions.inc +XA RECOVER; + +--error ER_XA_RBROLLBACK +XA COMMIT '1'; +--echo Must be no XA PREPARE group nor XA completion one: +--source include/show_binlog_events.inc +DROP TABLE t1; + +--source include/count_sessions.inc + +--connect(con2,localhost,root,,) +CREATE TABLE tm (a INT PRIMARY KEY) ENGINE=MyISAM; +XA START '1'; + --error ER_DUP_ENTRY + INSERT INTO tm VALUES (1),(1); + SELECT * FROM tm WHERE a = 2; +XA END '1'; +XA PREPARE '1'; + +--disconnect con2 + +--connection default +--source include/wait_until_count_sessions.inc +XA RECOVER; + +--error ER_XA_RBROLLBACK +XA ROLLBACK '1'; +--echo Must be no XA PREPARE group nor XA completion one: +--source include/show_binlog_events.inc +DROP TABLE tm; + diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 6dcd53e77c7..0bec01ab30b 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -440,6 +440,55 @@ SELECT * FROM (SELECT * FROM federated.t1 LIMIT 70000) dt; SELECT COUNT(DISTINCT a) FROM federated.t2; COUNT(DISTINCT a) 70000 +# +# MDEV-29640 FederatedX does not properly handle pushdown +# in case of difference in local and remote table names +# +connection master; +# Use tables from the previous test. Make sure pushdown works: +EXPLAIN SELECT COUNT(DISTINCT a) FROM federated.t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PUSHED SELECT NULL NULL NULL NULL NULL NULL NULL NULL +SELECT COUNT(DISTINCT a) FROM federated.t2; +COUNT(DISTINCT a) +70000 +# Link remote table `federated.t1` with the local table named `t1_local` +CREATE TABLE federated.t1_local ENGINE="FEDERATED" +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +# No pushdown here due to table names mismatch, retrieve data as usual: +EXPLAIN SELECT COUNT(DISTINCT a) FROM federated.t1_local; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1_local ALL NULL NULL NULL NULL 70000 +SELECT COUNT(DISTINCT a) FROM federated.t1_local; +COUNT(DISTINCT a) +70000 +# +# MDEV-29863 Server crashes in federatedx_txn::acquire after select from +# the Federated table with partitions and federated_pushdown=1 +# in case of difference in local and remote table names +# +connection slave; +CREATE TABLE federated.t3 (a INT); +INSERT INTO federated.t3 VALUES (1),(2),(3); +CREATE TABLE federated.t4 (a INT); +connection master; +CREATE SERVER fedlink FOREIGN DATA WRAPPER mysql +OPTIONS (USER 'root', HOST '127.0.0.1', DATABASE 'federated', +PORT SLAVE_PORT); +CREATE TABLE federated.t3 (a INT) +ENGINE=FEDERATED +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t3' + PARTITION BY list (a) +(PARTITION p1 VALUES IN (1) CONNECTION='fedlink/t3', +PARTITION p2 VALUES IN (2) CONNECTION='fedlink/t4'); +EXPLAIN SELECT * FROM federated.t3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t3 ALL NULL NULL NULL NULL 3 +SELECT * FROM federated.t3; +a +1 +2 +3 set global federated_pushdown=0; connection master; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index 8863a057b47..2d6c2bc4197 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -1,6 +1,7 @@ --source have_federatedx.inc --source include/federated.inc --source include/no_valgrind_without_big.inc +--source include/have_partition.inc connection default; @@ -266,6 +267,53 @@ INSERT INTO federated.t2 SELECT * FROM (SELECT * FROM federated.t1 LIMIT 70000) dt; SELECT COUNT(DISTINCT a) FROM federated.t2; + +--echo # +--echo # MDEV-29640 FederatedX does not properly handle pushdown +--echo # in case of difference in local and remote table names +--echo # +connection master; +--echo # Use tables from the previous test. Make sure pushdown works: +EXPLAIN SELECT COUNT(DISTINCT a) FROM federated.t2; +SELECT COUNT(DISTINCT a) FROM federated.t2; + +--echo # Link remote table `federated.t1` with the local table named `t1_local` +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval +CREATE TABLE federated.t1_local ENGINE="FEDERATED" +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +--echo # No pushdown here due to table names mismatch, retrieve data as usual: +EXPLAIN SELECT COUNT(DISTINCT a) FROM federated.t1_local; +SELECT COUNT(DISTINCT a) FROM federated.t1_local; + + +--echo # +--echo # MDEV-29863 Server crashes in federatedx_txn::acquire after select from +--echo # the Federated table with partitions and federated_pushdown=1 +--echo # in case of difference in local and remote table names +--echo # +connection slave; +CREATE TABLE federated.t3 (a INT); +INSERT INTO federated.t3 VALUES (1),(2),(3); +CREATE TABLE federated.t4 (a INT); + +connection master; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE SERVER fedlink FOREIGN DATA WRAPPER mysql + OPTIONS (USER 'root', HOST '127.0.0.1', DATABASE 'federated', + PORT $SLAVE_MYPORT); + +CREATE TABLE federated.t3 (a INT) + ENGINE=FEDERATED + CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t3' + PARTITION BY list (a) + (PARTITION p1 VALUES IN (1) CONNECTION='fedlink/t3', + PARTITION p2 VALUES IN (2) CONNECTION='fedlink/t4'); + +EXPLAIN SELECT * FROM federated.t3; +SELECT * FROM federated.t3; + set global federated_pushdown=0; source include/federated_cleanup.inc; diff --git a/mysql-test/suite/galera/disabled.def b/mysql-test/suite/galera/disabled.def index e518dca5a84..feac559ff55 100644 --- a/mysql-test/suite/galera/disabled.def +++ b/mysql-test/suite/galera/disabled.def @@ -37,4 +37,6 @@ query_cache: MDEV-15805 Test failure on galera.query_cache versioning_trx_id: MDEV-18590: galera.versioning_trx_id: Test failure: mysqltest: Result content mismatch galera_bf_abort_at_after_statement : Unstable galera_bf_abort_shutdown : MDEV-29773 Assertion failure on sql/wsrep_mysqld.cc:2893 in wsrep_bf_abort_shutdown - +galera.MW-284 : MDEV-29861: Galera test case hangs +galera.galera_binlog_checksum : MDEV-29861: Galera test case hangs +galera_var_notify_ssl_ipv6 : MDEV-29861: Galera test case hangs diff --git a/mysql-test/suite/galera/r/galera_many_rows.result b/mysql-test/suite/galera/r/galera_many_rows.result index 566bc59f8ab..b34c2484aea 100644 --- a/mysql-test/suite/galera/r/galera_many_rows.result +++ b/mysql-test/suite/galera/r/galera_many_rows.result @@ -5,32 +5,32 @@ connection node_2; connection node_1; SET SESSION innodb_lock_wait_timeout=600; SET SESSION lock_wait_timeout=600; -CREATE TABLE ten (f1 INTEGER) engine=InnoDB; +CREATE TABLE ten (f1 INTEGER NOT NULL PRIMARY KEY) engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; -INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; connection node_2; SET SESSION wsrep_sync_wait = 0; SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; SELECT COUNT(*) FROM t1; COUNT(*) -100000 -INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +10000 +INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; connection node_1; SELECT COUNT(*) FROM t1; COUNT(*) -200000 +20000 UPDATE t1 SET f2 = 1; connection node_2; SELECT COUNT(*) FROM t1 WHERE f2 = 1; COUNT(*) -200000 +20000 connection node_1; START TRANSACTION; SELECT COUNT(*) FROM t1; COUNT(*) -200000 +20000 UPDATE t1 SET f2 = 3; connection node_2; START TRANSACTION; diff --git a/mysql-test/suite/galera/t/galera_many_rows.test b/mysql-test/suite/galera/t/galera_many_rows.test index bc9e99db8da..3623b3f33b0 100644 --- a/mysql-test/suite/galera/t/galera_many_rows.test +++ b/mysql-test/suite/galera/t/galera_many_rows.test @@ -10,11 +10,11 @@ SET SESSION innodb_lock_wait_timeout=600; SET SESSION lock_wait_timeout=600; -CREATE TABLE ten (f1 INTEGER) engine=InnoDB; +CREATE TABLE ten (f1 INTEGER NOT NULL PRIMARY KEY) engine=InnoDB; INSERT INTO ten VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, f2 INTEGER) Engine=InnoDB; -INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; --connection node_2 SET SESSION wsrep_sync_wait = 0; @@ -24,7 +24,7 @@ SET SESSION wsrep_sync_wait = 15; SET GLOBAL wsrep_provider_options = 'repl.causal_read_timeout=PT1H'; SELECT COUNT(*) FROM t1; -INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4, ten AS a5; +INSERT INTO t1 (f2) SELECT a1.f1 FROM ten AS a1, ten AS a2, ten AS a3, ten AS a4; --connection node_1 SELECT COUNT(*) FROM t1; diff --git a/mysql-test/suite/innodb/r/instant_alter.result b/mysql-test/suite/innodb/r/instant_alter.result index 9cb5f9d2084..18680432c77 100644 --- a/mysql-test/suite/innodb/r/instant_alter.result +++ b/mysql-test/suite/innodb/r/instant_alter.result @@ -2929,3 +2929,14 @@ t1 CREATE TABLE `t1` ( KEY `f2` (`f2`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1, t2; +# +# MDEV-28822 Table from older version requires table rebuild when adding column to table with multi-column index +# +CREATE TABLE mdev28822_100427_innodb ( +id int not null primary key, +msg varchar(10), +index(id, msg) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +FLUSH TABLES; +ALTER TABLE mdev28822_100427_innodb ADD i1 INTEGER, ALGORITHM=INSTANT; +DROP TABLE mdev28822_100427_innodb; diff --git a/mysql-test/suite/innodb/t/instant_alter.test b/mysql-test/suite/innodb/t/instant_alter.test index 22815798f69..8e333e3bb72 100644 --- a/mysql-test/suite/innodb/t/instant_alter.test +++ b/mysql-test/suite/innodb/t/instant_alter.test @@ -1,6 +1,8 @@ --source include/innodb_page_size.inc --source include/have_sequence.inc +let $datadir=`select @@datadir`; + --echo # --echo # MDEV-11369: Instant ADD COLUMN for InnoDB --echo # @@ -949,3 +951,19 @@ ALTER TABLE t1 DROP COLUMN f3, ADD FOREIGN KEY fk (f1) ALTER TABLE t1 DROP COLUMN f5; SHOW CREATE TABLE t1; DROP TABLE t1, t2; + + +--echo # +--echo # MDEV-28822 Table from older version requires table rebuild when adding column to table with multi-column index +--echo # + +CREATE TABLE mdev28822_100427_innodb ( + id int not null primary key, + msg varchar(10), + index(id, msg) +) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +FLUSH TABLES; +remove_file $datadir/test/mdev28822_100427_innodb.frm; +copy_file std_data/mysql_upgrade/mdev28822_100427_innodb.frm $datadir/test/mdev28822_100427_innodb.frm; +ALTER TABLE mdev28822_100427_innodb ADD i1 INTEGER, ALGORITHM=INSTANT; +DROP TABLE mdev28822_100427_innodb; diff --git a/mysql-test/suite/plugins/t/false_dupes-6543.test b/mysql-test/suite/plugins/t/false_dupes-6543.test index ebdbe00e47c..ca278685967 100644 --- a/mysql-test/suite/plugins/t/false_dupes-6543.test +++ b/mysql-test/suite/plugins/t/false_dupes-6543.test @@ -1,3 +1,4 @@ +source include/not_embedded.inc; # # MDEV-6543 Crash if enable 'federatedx' when 'federated' plugin already enabled, and vice-versa # diff --git a/mysql-test/suite/rpl/include/rpl_xa_empty_transaction.inc b/mysql-test/suite/rpl/include/rpl_xa_empty_transaction.inc new file mode 100644 index 00000000000..4cb4fe8962f --- /dev/null +++ b/mysql-test/suite/rpl/include/rpl_xa_empty_transaction.inc @@ -0,0 +1,10 @@ +# +# Helper file to run each empty-due-to-err XA transaction test case both with +# and without detaching from the connection when the transaction is prepared. +# + +--let $use_disconnect=0 +--source rpl_xa_empty_transaction_test_case.inc + +--let $use_disconnect=1 +--source rpl_xa_empty_transaction_test_case.inc diff --git a/mysql-test/suite/rpl/include/rpl_xa_empty_transaction_test_case.inc b/mysql-test/suite/rpl/include/rpl_xa_empty_transaction_test_case.inc new file mode 100644 index 00000000000..6368336b8e3 --- /dev/null +++ b/mysql-test/suite/rpl/include/rpl_xa_empty_transaction_test_case.inc @@ -0,0 +1,131 @@ +# +# Helper script to create an XA transaction and validate it was not +# binlogged +# +# Parameters +# $xa_completion_action : The action to end the XA transaction, either +# COMMIT or ROLLBACK +# $trx_statements : A comma separated list specifying how to build +# the statements of the transaction. Each item in +# the list is either T (for transactional) or N +# (for non-transactional). An empty list will not +# add any statements to the transaction. +# $use_disconnect : When TRUE, disconnect after preparing the XA +# transaction to test the detach/rollback case +# + +# +# Setup +--let $generic_assert_text= should not binlog XA transaction + +--connection server_1 +--let server_1_datadir=`select @@datadir` + +--connection server_2 +--let server_2_datadir=`select @@datadir` + +--connection server_3 +--let server_3_datadir=`select @@datadir` + +--let assert_file=$MYSQLTEST_VARDIR/tmp/binlog_decoded.out + +--connection server_1 +CREATE TABLE tm (a INT PRIMARY KEY) engine=myisam; +CREATE TABLE ti (a INT PRIMARY KEY) engine=innodb; +--source include/save_master_gtid.inc + +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_1 + +if ($use_disconnect) +{ + --source include/count_sessions.inc + --connect(con1,localhost,root,,) +} + +XA START 'x'; +--let $_stmt_items= $trx_statements +--let $_ctr= 1 +while($_stmt_items) +{ + --let $_cur_stmt= `SELECT SUBSTRING_INDEX('$_stmt_items', ',', 1)` + --let $_stmt_items= `SELECT LTRIM(SUBSTRING('$_stmt_items', LENGTH('$_cur_stmt') + 2))` + + if (`SELECT strcmp("$_cur_stmt","T") = 0`) + { + --let $target_table= ti + } + + if (`SELECT strcmp("$_cur_stmt","N") = 0`) + { + --let $target_table= tm + } + + --error ER_DUP_ENTRY + --eval INSERT INTO $target_table VALUES ($_ctr),($_ctr); + inc $_ctr; + +} +XA END 'x'; +XA PREPARE 'x'; + +if ($use_disconnect) +{ + --disconnect con1 + --connection server_1 + --source include/wait_until_count_sessions.inc + XA RECOVER; + + --error ER_XA_RBROLLBACK + --eval XA $xa_completion_action 'x'; +} +if (!$use_disconnect) +{ + --eval XA $xa_completion_action 'x'; +} + +--source include/save_master_gtid.inc + +--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) +FLUSH LOGS; + +--echo # MYSQL_BINLOG server_1_datadir/binlog_filename --result-file=assert_file +--exec $MYSQL_BINLOG $server_1_datadir/$binlog_filename --result-file=$assert_file + +--let assert_text= server_1 $generic_assert_text +--let assert_count= 0 +--let assert_select= XA START|XA END|XA PREPARE|XA COMMIT|XA ROLLBACK +--source include/assert_grep.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) +FLUSH LOGS; + +--echo # MYSQL_BINLOG server_2_datadir/binlog_filename --result-file=assert_file +--exec $MYSQL_BINLOG $server_2_datadir/$binlog_filename --result-file=$assert_file + +--let assert_text= server_2 $generic_assert_text +--source include/assert_grep.inc + +--connection server_3 +--source include/sync_with_master_gtid.inc +--let binlog_filename= query_get_value(SHOW MASTER STATUS, File, 1) +FLUSH LOGS; + +--echo # MYSQL_BINLOG server_3_datadir/binlog_filename --result-file=assert_file +--exec $MYSQL_BINLOG $server_3_datadir/$binlog_filename --result-file=$assert_file + +--let assert_text= server_3 $generic_assert_text +--source include/assert_grep.inc + +# +# Cleanup +--connection server_1 +DROP TABLE ti,tm; +--source include/save_master_gtid.inc + +--connection server_3 +--source include/sync_with_master_gtid.inc diff --git a/mysql-test/suite/rpl/r/rpl_xa_empty_transaction.result b/mysql-test/suite/rpl/r/rpl_xa_empty_transaction.result new file mode 100644 index 00000000000..f3ea53c219a --- /dev/null +++ b/mysql-test/suite/rpl/r/rpl_xa_empty_transaction.result @@ -0,0 +1,1169 @@ +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; +connection server_1; +include/rpl_end.inc +# End of rpl_xa_empty_transaction.test diff --git a/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.cnf b/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.cnf new file mode 100644 index 00000000000..92acd0c73a6 --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.cnf @@ -0,0 +1,18 @@ +!include include/default_mysqld.cnf + +[mysqld.1] +log-slave-updates +innodb + +[mysqld.2] +log-slave-updates +innodb + +[mysqld.3] +log-slave-updates +innodb + +[ENV] +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYPORT_3= @mysqld.3.port diff --git a/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.test b/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.test new file mode 100644 index 00000000000..61cc0621d5a --- /dev/null +++ b/mysql-test/suite/rpl/t/rpl_xa_empty_transaction.test @@ -0,0 +1,175 @@ +# +# Purpose: +# This test ensures consistency in binlogging behavior for XA transactions +# that have all statements error and rollback, effectively leaving an "empty" +# transaction. In such cases, an empty XA transaction should be binlogged. The +# bug reported by MDEV-25616 revealed that an "empty" XA transaction would +# binlog an XA ROLLBACK or XA COMMIT event without a preceding setup, i.e. +# XA START through XA PREPARE. The bug presented differently for XA +# transactions consisting of transactional and non-transactional statements. +# Therefore, this test validates that an entire XA transaction is binlogged +# for different combinations of transactional or non-transactional statements. +# Note that the behavior changes when binlogging empty XA transactions +# depending on the binlog_row_format variables. That is, when the content of +# the transaction consists of errored transactional statements, in row format, +# an empty XA transaction will be binlogged; however, in mixed and statement +# formats, nothing will be written into the binary log. +# +# Methodology: +# Create XA transactions with various combinations of erroring transactional +# or non-transactional statements. The binary log is examined to ensure all +# XA components are written. Chain replication is used, i.e. +# (primary->replica->replica), to ensure replica binlogging is consistent with +# manual execution. The transactional and non-transactional tables use InnoDB +# and MyISAM, respectively. +# +# Parameters +# $expect_transactional_xa_binlog : Boolean indicating whether or not an +# errored transactional statement should result in XA statements written +# into the binary log. +# +# References: +# MDEV-25616: Binlog event for XA COMMIT is generated without matching +# XA START, replication aborts +# +--source include/have_log_bin.inc + +--let $rpl_server_count= 3 +--let $rpl_topology= 1->2->3 +--source include/rpl_init.inc + +--connection server_1 +-- source include/have_innodb.inc +--connection server_2 +-- source include/have_innodb.inc +--connection server_3 +-- source include/have_innodb.inc +--connection server_1 + +--echo # +--echo # Test Case 1: An XA transaction without any statements should not be +--echo # binlogged +--let $trx_statements= + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + + +--echo # +--echo # Test Case 2: An XA transaction consisting of a successfully rolled back +--echo # statement should not be binlogged +--let $trx_statements= T + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + + +--echo # +--echo # Test Case 3: An XA transaction with a statement that cannot be rolled +--echo # back should be binlogged + +# TODO: remove work-around MDEV-24654 when fixed. +--connection server_1 +set @sav_binlog_format = @@binlog_format; +set @@binlog_format = row; +set @@global.binlog_format = row; +--let $trx_statements= N + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + +--connection server_1 +set @@binlog_format = @sav_binlog_format; +set @@global.binlog_format = @sav_binlog_format; + + +--echo # +--echo # Test Case 4: An XA transaction with multiple statements that can all +--echo # be rolled back should not be binlogged +--let $trx_statements= T,T + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + + +--echo # +--echo # Test Case 5: A mixed XA transaction consisting of one statement that +--echo # can successfully be rolled back (first statement), and another that +--echo # 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; +--let $trx_statements= T,N + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + +--connection server_1 +set @@binlog_format = @sav_binlog_format; +set @@global.binlog_format = @sav_binlog_format; + + +--echo # +--echo # Test Case 6: A mixed XA transaction consisting of one statement that +--echo # cannot successfully be rolled back (first statement), and another that +--echo # can (second statement) should be binlogged + +--connection server_1 +set @sav_binlog_format = @@binlog_format; +set @@binlog_format = row; +set @@global.binlog_format = row; +--let $trx_statements= N,T + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + +--connection server_1 +set @@binlog_format = @sav_binlog_format; +set @@global.binlog_format = @sav_binlog_format; + +--echo # +--echo # Test Case 7: An XA transaction consisting of two failed +--echo # non-transactional statements should be binlogged + +--connection server_1 +set @sav_binlog_format = @@binlog_format; +set @@binlog_format = row; +set @@global.binlog_format = row; +--let $trx_statements= N,N + +--let $xa_completion_action= COMMIT +--source include/rpl_xa_empty_transaction.inc + +--let $xa_completion_action= ROLLBACK +--source include/rpl_xa_empty_transaction.inc + +--connection server_1 +set @@binlog_format = @sav_binlog_format; +set @@global.binlog_format = @sav_binlog_format; + +# +# Cleanup +--connection server_1 +--source include/rpl_end.inc + +--echo # End of rpl_xa_empty_transaction.test |