2016-12-19 17:32:45 -05:00
call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction");
2005-04-04 00:50:05 +02:00
drop table if exists t1, t2;
create table t1 (a int) engine=innodb;
xa start 'test1';
insert t1 values (10);
xa end 'test1';
xa prepare 'test1';
xa rollback 'test1';
select * from t1;
a
xa start 'test2';
xa start 'test-bad';
2005-10-05 19:58:16 +02:00
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
2005-04-04 00:50:05 +02:00
insert t1 values (20);
xa prepare 'test2';
2005-10-05 19:58:16 +02:00
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
2005-04-04 00:50:05 +02:00
xa end 'test2';
xa prepare 'test2';
xa commit 'test2';
select * from t1;
a
20
xa start 'testa','testb';
insert t1 values (30);
2005-10-05 19:58:16 +02:00
commit;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
2005-04-04 00:50:05 +02:00
xa end 'testa','testb';
2005-10-05 19:58:16 +02:00
begin;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
create table t2 (a int);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
2016-03-25 20:51:22 +04:00
connect con1,localhost,root,,;
connection con1;
2005-08-12 21:15:01 +02:00
xa start 'testa','testb';
ERROR XAE08: XAER_DUPID: The XID already exists
2005-10-05 16:38:53 +02:00
xa start 'testa','testb', 123;
ERROR XAE08: XAER_DUPID: The XID already exists
2005-04-04 00:50:05 +02:00
xa start 0x7465737462, 0x2030405060, 0xb;
insert t1 values (40);
xa end 'testb',' 0@P`',11;
xa prepare 'testb',0x2030405060,11;
2005-10-05 19:58:16 +02:00
start transaction;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
2005-04-04 00:50:05 +02:00
xa recover;
formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
2016-03-25 20:51:22 +04:00
connection default;
2005-04-04 00:50:05 +02:00
xa prepare 'testa','testb';
xa recover;
formatID gtrid_length bqual_length data
11 5 5 testb 0@P`
1 5 5 testatestb
xa commit 'testb',0x2030405060,11;
2020-03-02 17:12:35 +02:00
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
2005-04-04 00:50:05 +02:00
xa rollback 'testa','testb';
xa start 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';
2011-12-12 23:58:40 +01:00
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
2005-04-04 00:50:05 +02:00
select * from t1;
a
20
2016-03-25 20:51:22 +04:00
disconnect con1;
MDEV-742 XA PREPAREd transaction survive disconnect/server restart
Lifted long standing limitation to the XA of rolling it back at the
transaction's
connection close even if the XA is prepared.
Prepared XA-transaction is made to sustain connection close or server
restart.
The patch consists of
- binary logging extension to write prepared XA part of
transaction signified with
its XID in a new XA_prepare_log_event. The concusion part -
with Commit or Rollback decision - is logged separately as
Query_log_event.
That is in the binlog the XA consists of two separate group of
events.
That makes the whole XA possibly interweaving in binlog with
other XA:s or regular transaction but with no harm to
replication and data consistency.
Gtid_log_event receives two more flags to identify which of the
two XA phases of the transaction it represents. With either flag
set also XID info is added to the event.
When binlog is ON on the server XID::formatID is
constrained to 4 bytes.
- engines are made aware of the server policy to keep up user
prepared XA:s so they (Innodb, rocksdb) don't roll them back
anymore at their disconnect methods.
- slave applier is refined to cope with two phase logged XA:s
including parallel modes of execution.
This patch does not address crash-safe logging of the new events which
is being addressed by MDEV-21469.
CORNER CASES: read-only, pure myisam, binlog-*, @@skip_log_bin, etc
Are addressed along the following policies.
1. The read-only at reconnect marks XID to fail for future
completion with ER_XA_RBROLLBACK.
2. binlog-* filtered XA when it changes engine data is regarded as
loggable even when nothing got cached for binlog. An empty
XA-prepare group is recorded. Consequent Commit-or-Rollback
succeeds in the Engine(s) as well as recorded into binlog.
3. The same applies to the non-transactional engine XA.
4. @@skip_log_bin=OFF does not record anything at XA-prepare
(obviously), but the completion event is recorded into binlog to
admit inconsistency with slave.
The following actions are taken by the patch.
At XA-prepare:
when empty binlog cache - don't do anything to binlog if RO,
otherwise write empty XA_prepare (assert(binlog-filter case)).
At Disconnect:
when Prepared && RO (=> no binlogging was done)
set Xid_cache_element::error := ER_XA_RBROLLBACK
*keep* XID in the cache, and rollback the transaction.
At XA-"complete":
Discover the error, if any don't binlog the "complete",
return the error to the user.
Kudos
-----
Alexey Botchkov took to drive this work initially.
Sergei Golubchik, Sergei Petrunja, Marko Mäkelä provided a number of
good recommendations.
Sergei Voitovich made a magnificent review and improvements to the code.
They all deserve a bunch of thanks for making this work done!
2019-03-31 01:47:28 +04:00
xa rollback 'testb',0x2030405060,11;
xa recover;
formatID gtrid_length bqual_length data
2016-03-25 20:51:22 +04:00
connection default;
2017-12-18 01:55:40 +04:00
xa start 'tr1';
insert t1 values (40);
xa end 'tr1';
xa prepare 'tr1';
xa recover format='SQL';
formatID gtrid_length bqual_length data
1 3 0 'tr1'
xa rollback 'tr1';
xa start 'tr1', 'bq';
insert t1 values (40);
xa end 'tr1', 'bq';
xa prepare 'tr1', 'bq';
xa recover format='SQL';
formatID gtrid_length bqual_length data
1 3 2 'tr1','bq'
xa rollback 'tr1', 'bq';
xa start 'tr1', 'bq', 3;
insert t1 values (40);
xa end 'tr1', 'bq', 3;
xa prepare 'tr1', 'bq', 3;
xa recover format='SQL';
formatID gtrid_length bqual_length data
3 3 2 'tr1','bq',3
xa rollback 'tr1', 'bq', 3;
xa start 'tr1#$';
insert t1 values (40);
xa end 'tr1#$';
xa prepare 'tr1#$';
xa recover format='SQL';
formatID gtrid_length bqual_length data
1 5 0 X'7472312324'
xa rollback 'tr1#$';
xa start 'tr1#$', 'bq';
insert t1 values (40);
xa end 'tr1#$', 'bq';
xa prepare 'tr1#$', 'bq';
xa recover format='SQL';
formatID gtrid_length bqual_length data
1 5 2 X'7472312324',X'6271'
xa rollback 'tr1#$', 'bq';
xa start 'tr1#$', 'bq', 3;
insert t1 values (40);
xa end 'tr1#$', 'bq', 3;
xa prepare 'tr1#$', 'bq', 3;
xa recover format='RAW';
formatID gtrid_length bqual_length data
3 5 2 tr1#$bq
xa recover format='PLAIN';
ERROR HY000: Unknown XA RECOVER format name: 'PLAIN'
xa recover format='SQL';
formatID gtrid_length bqual_length data
3 5 2 X'7472312324',X'6271',3
xa rollback 'tr1#$', 'bq', 3;
2005-04-04 00:50:05 +02:00
drop table t1;
2008-10-21 16:07:31 -02:00
drop table if exists t1;
create table t1(a int, b int, c varchar(20), primary key(a)) engine = innodb;
insert into t1 values(1, 1, 'a');
insert into t1 values(2, 2, 'b');
2016-03-25 20:51:22 +04:00
connect con1,localhost,root,,;
connect con2,localhost,root,,;
connection con1;
2008-10-21 16:07:31 -02:00
xa start 'a','b';
update t1 set c = 'aa' where a = 1;
2016-03-25 20:51:22 +04:00
connection con2;
2008-10-21 16:07:31 -02:00
xa start 'a','c';
update t1 set c = 'bb' where a = 2;
2016-03-25 20:51:22 +04:00
connection con1;
2008-10-21 16:07:31 -02:00
update t1 set c = 'bb' where a = 2;
2016-03-25 20:51:22 +04:00
connection con2;
2008-10-21 16:07:31 -02:00
update t1 set c = 'aa' where a = 1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
select count(*) from t1;
count(*)
2
xa end 'a','c';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
xa rollback 'a','c';
2016-03-25 20:51:22 +04:00
disconnect con2;
connect con3,localhost,root,,;
connection con3;
2008-10-21 16:07:31 -02:00
xa start 'a','c';
2016-03-25 20:51:22 +04:00
disconnect con1;
disconnect con3;
connection default;
2008-10-21 19:02:26 -02:00
drop table t1;
2010-03-10 15:04:32 +04:00
#
# BUG#51342 - more xid crashing
#
CREATE TABLE t1(a INT) ENGINE=InnoDB;
XA START 'x';
SET SESSION autocommit=0;
INSERT INTO t1 VALUES(1);
SET SESSION autocommit=1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
SELECT @@autocommit;
@@autocommit
0
INSERT INTO t1 VALUES(1);
XA END 'x';
XA COMMIT 'x' ONE PHASE;
DROP TABLE t1;
2010-03-10 19:28:49 +04:00
SET SESSION autocommit=1;
2008-10-21 16:07:31 -02:00
End of 5.0 tests
2009-06-05 19:16:54 -03:00
xa start 'a';
xa end 'a';
xa rollback 'a';
xa start 'a';
xa end 'a';
xa rollback 'a';
2009-06-25 12:25:23 -03:00
xa start 'a';
xa end 'a';
xa prepare 'a';
xa commit 'a';
xa start 'a';
xa end 'a';
xa prepare 'a';
xa commit 'a';
2009-10-28 19:39:08 +04:00
CREATE TABLE t1(a INT, KEY(a)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(1),(2);
2016-03-25 20:51:22 +04:00
connect con1,localhost,root,,;
2009-10-28 19:39:08 +04:00
BEGIN;
UPDATE t1 SET a=3 WHERE a=1;
2016-03-25 20:51:22 +04:00
connection default;
2009-10-28 19:39:08 +04:00
BEGIN;
UPDATE t1 SET a=4 WHERE a=2;
2016-03-25 20:51:22 +04:00
connection con1;
2009-10-28 19:39:08 +04:00
UPDATE t1 SET a=5 WHERE a=2;
2016-03-25 20:51:22 +04:00
connection default;
2009-10-28 19:39:08 +04:00
UPDATE t1 SET a=5 WHERE a=1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
ROLLBACK;
2016-03-25 20:51:22 +04:00
connection con1;
2009-10-28 19:39:08 +04:00
ROLLBACK;
BEGIN;
UPDATE t1 SET a=3 WHERE a=1;
2016-03-25 20:51:22 +04:00
connection default;
2009-10-28 19:39:08 +04:00
XA START 'xid1';
UPDATE t1 SET a=4 WHERE a=2;
2016-03-25 20:51:22 +04:00
connection con1;
2009-10-28 19:39:08 +04:00
UPDATE t1 SET a=5 WHERE a=2;
2016-03-25 20:51:22 +04:00
connection default;
2009-10-28 19:39:08 +04:00
UPDATE t1 SET a=5 WHERE a=1;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA END 'xid1';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
XA ROLLBACK 'xid1';
XA START 'xid1';
XA END 'xid1';
XA ROLLBACK 'xid1';
2016-03-25 20:51:22 +04:00
disconnect con1;
2009-10-28 19:39:08 +04:00
DROP TABLE t1;
2010-09-13 13:31:22 +02:00
#
# Bug#56448 Assertion failed: ! is_set() with second xa end
#
XA START 'x';
XA END 'x';
XA END 'x';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA PREPARE 'x';
XA PREPARE 'x';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
XA ROLLBACK 'x';
2011-02-14 14:16:31 +01:00
#
# Bug#59986 Assert in Diagnostics_area::set_ok_status() for XA COMMIT
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a INT, b INT, PRIMARY KEY(a)) engine=InnoDB;
INSERT INTO t1 VALUES (1, 1), (2, 2);
2016-03-25 20:51:22 +04:00
connect con1, localhost, root;
2011-02-14 14:16:31 +01:00
XA START 'a';
UPDATE t1 SET b= 3 WHERE a=1;
2016-03-25 20:51:22 +04:00
connection default;
2011-02-14 14:16:31 +01:00
XA START 'b';
UPDATE t1 SET b=4 WHERE a=2;
# Sending:
UPDATE t1 SET b=5 WHERE a=1;
2016-03-25 20:51:22 +04:00
connection con1;
2011-02-14 14:16:31 +01:00
UPDATE t1 SET b=6 WHERE a=2;
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA COMMIT 'a';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
2016-03-25 20:51:22 +04:00
connection default;
2011-02-14 14:16:31 +01:00
# Reaping: UPDATE t1 SET b=5 WHERE a=1
XA END 'b';
XA ROLLBACK 'b';
DROP TABLE t1;
2016-03-25 20:51:22 +04:00
disconnect con1;
2011-04-12 12:57:02 +02:00
#
# Bug#11766752 59936: multiple xa assertions - transactional
# statement fuzzer
#
CREATE TABLE t1 (a INT) engine=InnoDB;
XA START 'a';
INSERT INTO t1 VALUES (1);
SAVEPOINT savep;
XA END 'a';
SELECT * FROM t1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
INSERT INTO t1 VALUES (2);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
SAVEPOINT savep;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
SET @a=(SELECT * FROM t1);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA PREPARE 'a';
SELECT * FROM t1;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
INSERT INTO t1 VALUES (2);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
SAVEPOINT savep;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
SET @a=(SELECT * FROM t1);
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
UPDATE t1 SET a=1 WHERE a=2;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
XA COMMIT 'a';
SELECT * FROM t1;
a
1
DROP TABLE t1;
2011-04-14 10:13:28 +02:00
#
2018-01-15 13:50:28 +04:00
# MDEV-14609 XA Transction unable to ROLLBACK TO SAVEPOINT
#
CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
XA START 'xa1';
SAVEPOINT savepoint1;
INSERT INTO t1 (c1) VALUES (1),(2),(3),(4);
ROLLBACK TO SAVEPOINT savepoint1;
XA END 'xa1';
XA ROLLBACK 'xa1';
DROP TABLE t1;
#
2011-04-14 10:13:28 +02:00
# Bug#12352846 - TRANS_XA_START(THD*):
# ASSERTION THD->TRANSACTION.XID_STATE.XID.IS_NULL()
2020-11-30 15:29:32 +02:00
# FAILED
2011-04-14 10:13:28 +02:00
#
2012-01-20 16:03:39 +06:00
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
2018-07-03 15:10:06 +03:00
INSERT INTO t2 VALUES (1);
COMMIT;
BEGIN;
INSERT INTO t2 VALUES (2);
UPDATE t2 SET a=a+1;
2016-03-25 20:51:22 +04:00
connect con2,localhost,root;
2011-04-14 10:13:28 +02:00
XA START 'xid1';
2018-07-03 15:10:06 +03:00
INSERT INTO t1 VALUES (1);
2011-04-14 10:13:28 +02:00
# Sending:
2018-07-03 15:10:06 +03:00
DELETE FROM t2;
2016-03-25 20:51:22 +04:00
connection default;
2011-04-14 10:13:28 +02:00
DELETE FROM t1;
2016-03-25 20:51:22 +04:00
connection con2;
2011-04-14 10:13:28 +02:00
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
XA COMMIT 'xid1';
ERROR XA102: XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected
2016-03-25 20:51:22 +04:00
connection default;
2012-01-20 16:03:39 +06:00
COMMIT;
2016-03-25 20:51:22 +04:00
connection con2;
2011-04-14 10:13:28 +02:00
XA START 'xid1';
XA END 'xid1';
XA PREPARE 'xid1';
XA ROLLBACK 'xid1';
2016-03-25 20:51:22 +04:00
connection default;
2011-04-14 10:13:28 +02:00
DROP TABLE t1, t2;
2016-03-25 20:51:22 +04:00
disconnect con2;
2018-03-12 08:30:08 +04:00
CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t2 VALUES (1),(2);
CREATE TABLE t3 (i INT) ENGINE=InnoDB;
XA BEGIN 'xid1';
REPLACE INTO t1 SELECT * FROM t2;
connect con1,localhost,root,,test;
XA BEGIN 'xid2';
INSERT INTO t1 SELECT * FROM t2;
connection default;
REPLACE INTO t2 SELECT * FROM t2;
connection con1;
disconnect con1;
connect con2,localhost,root,,test;
INSERT INTO t3 VALUES (1);
XA BEGIN 'xid3';
disconnect con2;
connection default;
XA END 'xid1';
XA ROLLBACK 'xid1';
DROP TABLE t1, t2, t3;
2020-02-28 19:08:35 +04:00
#
2020-11-30 15:29:32 +02:00
# MDEV 15532 XA: Assertion `!log->same_pk' failed in
# row_log_table_apply_delete
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1),(2);
connect con1,localhost,root,,test;
XA START 'xid';
UPDATE t1 SET a = 5;
connection default;
SET innodb_lock_wait_timeout= 2, lock_wait_timeout= 2;
ALTER TABLE non_existing_table1;
ERROR 42S02: Table 'test.non_existing_table1' doesn't exist
ALTER TABLE t1 FORCE;;
connection con1;
ALTER TABLE non_existing_table2;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
DELETE FROM t1 LIMIT 1;
connection default;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
connection con1;
XA END 'xid';
XA ROLLBACK 'xid';
DROP TABLE t1;
disconnect con1;
connection default;
2020-12-02 18:29:49 +02:00
#
2020-02-28 19:08:35 +04:00
# MDEV-21766 - Forbid XID with empty 'gtrid'
#
CREATE TABLE t1(a INT) ENGINE=InnoDB;
XA BEGIN '';
ERROR XAE05: XAER_INVAL: Invalid arguments (or unsupported command)
XA BEGIN '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x',
'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x';
INSERT INTO t1 VALUES(1);
XA END '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x',
'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x';
XA PREPARE '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x',
'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x';
XA ROLLBACK '8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x',
'8bytes1x8bytes2x8bytes3x8bytes4x8bytes5x8bytes6x8bytes7x8bytes8x';
SET NAMES utf8;
XA BEGIN 'Я_у па ла _с _с е но ва ла _то р мо зила _г о ло во й';
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
XA BEGIN 'Я_у пaлa_c_с е но ва ла _то р мо зила _г о ло во й';
XA END 'Я_у пaлa_c_с е но ва ла _то р мо зила _г о ло во й';
XA PREPARE 'Я_у пaлa_c_с е но ва ла _то р мо зила _г о ло во й';
XA ROLLBACK 'Я_у пaлa_c_с е но ва ла _то р мо зила _г о ло во й';
SET NAMES default;
DROP TABLE t1;
2020-03-09 18:31:18 +04:00
#
2020-03-02 17:12:35 +02:00
# MDEV-21659 XA rollback foreign_xid is allowed inside active XA
# MDEV-21854 - xa commit one phase for already prepared transaction
# must always error out
#
BEGIN;
XA COMMIT 'unknown';
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
XA COMMIT 'unknown' ONE PHASE;
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
BEGIN;
XA ROLLBACK 'unknown';
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
ROLLBACK;
XA START 'xid1';
XA COMMIT 'unknown';
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
XA COMMIT 'unknown' ONE PHASE;
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
XA ROLLBACK 'unknown';
ERROR XAE09: XAER_OUTSIDE: Some work is done outside global transaction
XA END 'xid1';
XA PREPARE 'xid1';
XA COMMIT 'xid1' ONE PHASE;
ERROR XAE05: XAER_INVAL: Invalid arguments (or unsupported command)
XA ROLLBACK 'xid1';
#
2020-03-09 18:31:18 +04:00
# MDEV-21856 - xid_t::formatID has to be constrained to 4 byte size
#
XA START 'gtrid', 'bqual', 0x80000000;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '0x80000000' at line 1
2021-05-10 10:01:15 +03:00
#
2021-05-03 18:10:13 +02:00
# XA states and SHOW commands
#
create table t1 (pk int primary key) engine=innodb;
xa start 'foo';
insert t1 set pk=1;
xa end 'foo';
xa prepare 'foo';
show status like 'foo';
Variable_name Value
select table_name,table_comment from information_schema.tables where table_schema='test';
table_name t1
table_comment
select table_name,table_rows,table_comment from information_schema.tables where table_schema='test';
table_name t1
table_rows NULL
table_comment XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
Warnings:
Level Warning
Code 1399
Message XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
xa commit 'foo';
drop table t1;
#
# End of 10.2 tests
#
2020-05-22 15:42:11 +03:00
XA BEGIN 'xid';
CREATE TEMPORARY SEQUENCE s;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
XA END 'xid';
XA ROLLBACK 'xid';
XA BEGIN 'xid';
CREATE SEQUENCE s;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
XA END 'xid';
XA ROLLBACK 'xid';
#
# End of 10.3 tests
#
2020-05-31 10:28:59 +03:00
#
# Start of 10.5 tests
#
MDEV-742 XA PREPAREd transaction survive disconnect/server restart
Lifted long standing limitation to the XA of rolling it back at the
transaction's
connection close even if the XA is prepared.
Prepared XA-transaction is made to sustain connection close or server
restart.
The patch consists of
- binary logging extension to write prepared XA part of
transaction signified with
its XID in a new XA_prepare_log_event. The concusion part -
with Commit or Rollback decision - is logged separately as
Query_log_event.
That is in the binlog the XA consists of two separate group of
events.
That makes the whole XA possibly interweaving in binlog with
other XA:s or regular transaction but with no harm to
replication and data consistency.
Gtid_log_event receives two more flags to identify which of the
two XA phases of the transaction it represents. With either flag
set also XID info is added to the event.
When binlog is ON on the server XID::formatID is
constrained to 4 bytes.
- engines are made aware of the server policy to keep up user
prepared XA:s so they (Innodb, rocksdb) don't roll them back
anymore at their disconnect methods.
- slave applier is refined to cope with two phase logged XA:s
including parallel modes of execution.
This patch does not address crash-safe logging of the new events which
is being addressed by MDEV-21469.
CORNER CASES: read-only, pure myisam, binlog-*, @@skip_log_bin, etc
Are addressed along the following policies.
1. The read-only at reconnect marks XID to fail for future
completion with ER_XA_RBROLLBACK.
2. binlog-* filtered XA when it changes engine data is regarded as
loggable even when nothing got cached for binlog. An empty
XA-prepare group is recorded. Consequent Commit-or-Rollback
succeeds in the Engine(s) as well as recorded into binlog.
3. The same applies to the non-transactional engine XA.
4. @@skip_log_bin=OFF does not record anything at XA-prepare
(obviously), but the completion event is recorded into binlog to
admit inconsistency with slave.
The following actions are taken by the patch.
At XA-prepare:
when empty binlog cache - don't do anything to binlog if RO,
otherwise write empty XA_prepare (assert(binlog-filter case)).
At Disconnect:
when Prepared && RO (=> no binlogging was done)
set Xid_cache_element::error := ER_XA_RBROLLBACK
*keep* XID in the cache, and rollback the transaction.
At XA-"complete":
Discover the error, if any don't binlog the "complete",
return the error to the user.
Kudos
-----
Alexey Botchkov took to drive this work initially.
Sergei Golubchik, Sergei Petrunja, Marko Mäkelä provided a number of
good recommendations.
Sergei Voitovich made a magnificent review and improvements to the code.
They all deserve a bunch of thanks for making this work done!
2019-03-31 01:47:28 +04:00
# MDEV-7974 related
# Check XA state when lock_wait_timeout happens
# More tests added to flush_read_lock.test
connect con_tmp,localhost,root,,;
set session lock_wait_timeout=1;
create table asd (a int) engine=innodb;
xa start 'test1';
insert into asd values(1);
xa end 'test1';
connection default;
flush table with read lock;
connection con_tmp;
# PREPARE error will do auto rollback.
xa prepare 'test1';
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
show errors;
Level Code Message
Error 1205 Lock wait timeout exceeded; try restarting transaction
Error 1402 XA_RBROLLBACK: Transaction branch was rolled back
connection default;
unlock tables;
connection con_tmp;
xa start 'test1';
insert into asd values(1);
xa end 'test1';
xa prepare 'test1';
connection default;
flush tables with read lock;
connection con_tmp;
# LOCK error during ROLLBACK will not alter transaction state.
xa rollback 'test1';
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
show errors;
Level Code Message
Error 1205 Lock wait timeout exceeded; try restarting transaction
Error 1401 XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency
xa recover;
formatID gtrid_length bqual_length data
1 5 0 test1
# LOCK error during COMMIT will not alter transaction state.
xa commit 'test1';
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
show errors;
Level Code Message
Error 1205 Lock wait timeout exceeded; try restarting transaction
Error 1401 XAER_RMERR: Fatal error occurred in the transaction branch - check your data for consistency
xa recover;
formatID gtrid_length bqual_length data
1 5 0 test1
connection default;
unlock tables;
connection con_tmp;
xa rollback 'test1';
xa recover;
formatID gtrid_length bqual_length data
drop table asd;
disconnect con_tmp;
connection default;
2020-05-31 10:28:59 +03:00
#
# End of 10.5 tests
#