mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
388296a1e6
In `pseudo_slave_mode=1` aka "psedo-slave" mode any prepared XA transaction disconnects from the user session, as if the user connection drops. The xid of such transaction remains in the server, and should the prepared transaction be read-only, it is marked. The marking makes sure that the following termination of the read-only transaction ends up with ER_XA_RBROLLBACK. This did not take place actually for `pseudo_slave_mode=1` read-only. Fixed with checking the read-only status of a prepared transaction at time it disconnects from the `pseudo_slave_mode=1` session, to mark its xid when that's the case.
227 lines
10 KiB
Text
227 lines
10 KiB
Text
RESET MASTER;
|
|
CREATE TEMPORARY SEQUENCE seq_1;
|
|
XA START '3';
|
|
CREATE TEMPORARY TABLE tmp_1(c INT);
|
|
XA END '3';
|
|
XA PREPARE '3';
|
|
DROP TEMPORARY TABLE tmp_1;
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
ALTER TABLE tmp_1 DROP COLUMN c;
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
DROP TEMPORARY SEQUENCE seq_1;
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
ALTER SEQUENCE seq_1 INCREMENT BY 1;
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
CREATE TEMPORARY TABLE tmp_2(c INT);
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
CREATE TEMPORARY SEQUENCE seq_2;
|
|
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the PREPARED state
|
|
XA ROLLBACK '3';
|
|
# Proof of correct logging incl empty XA-PREPARE
|
|
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 TEMPORARY SEQUENCE seq_1
|
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; CREATE TEMPORARY TABLE tmp_1(c INT)
|
|
master-bin.000001 # Query # # COMMIT
|
|
master-bin.000001 # Gtid # # XA START X'33',X'',1 GTID #-#-#
|
|
master-bin.000001 # Query # # XA END X'33',X'',1
|
|
master-bin.000001 # XA_prepare # # XA PREPARE X'33',X'',1
|
|
master-bin.000001 # Gtid # # GTID #-#-#
|
|
master-bin.000001 # Query # # XA ROLLBACK X'33',X'',1
|
|
RESET MASTER;
|
|
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
|
|
CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (1),(2);
|
|
INSERT INTO t2 VALUES (1),(2);
|
|
XA START '1';
|
|
REPLACE INTO t1 SELECT * FROM t1;
|
|
REPLACE INTO t2 SELECT * FROM t2;
|
|
XA END '1';
|
|
XA PREPARE '1';
|
|
XA ROLLBACK '1';
|
|
Warnings:
|
|
Warning 1196 Some non-transactional changed tables couldn't be rolled back
|
|
DROP TABLE t1, t2;
|
|
# Proof of correct logging incl empty XA-PREPARE
|
|
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) ENGINE=MyISAM
|
|
master-bin.000001 # Gtid # # GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=InnoDB
|
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1),(2)
|
|
master-bin.000001 # Query # # COMMIT
|
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; INSERT INTO t2 VALUES (1),(2)
|
|
master-bin.000001 # Xid # # COMMIT /* XID */
|
|
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
|
|
master-bin.000001 # Annotate_rows # # REPLACE INTO t1 SELECT * FROM t1
|
|
master-bin.000001 # Table_map # # table_id: # (test.t1)
|
|
master-bin.000001 # Write_rows_v1 # # table_id: # flags: STMT_END_F
|
|
master-bin.000001 # Query # # COMMIT
|
|
master-bin.000001 # Gtid # # XA START X'31',X'',1 GTID #-#-#
|
|
master-bin.000001 # Query # # XA END X'31',X'',1
|
|
master-bin.000001 # XA_prepare # # XA PREPARE X'31',X'',1
|
|
master-bin.000001 # Gtid # # GTID #-#-#
|
|
master-bin.000001 # Query # # XA ROLLBACK X'31',X'',1
|
|
master-bin.000001 # Gtid # # GTID #-#-#
|
|
master-bin.000001 # Query # # use `test`; DROP TABLE `t1`,`t2` /* generated by server */
|
|
RESET MASTER;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
|
|
INSERT INTO t1 VALUES (1);
|
|
CREATE SEQUENCE s ENGINE=InnoDB;
|
|
XA START '2';
|
|
SELECT NEXT VALUE FOR s;
|
|
NEXT VALUE FOR s
|
|
1
|
|
REPLACE INTO t1 SELECT * FROM t1;
|
|
XA END '2';
|
|
XA PREPARE '2';
|
|
XA ROLLBACK '2';
|
|
DROP SEQUENCE s;
|
|
DROP TABLE t1;
|
|
# Proof of correct logging incl empty XA-PREPARE
|
|
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 */
|
|
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;
|
|
connection default;
|
|
SET pseudo_slave_mode=1;
|
|
XA START 'a';
|
|
XA END 'a';
|
|
XA PREPARE 'a';
|
|
XA ROLLBACK 'a';
|
|
ERROR XA100: XA_RBROLLBACK: Transaction branch was rolled back
|
|
include/show_binlog_events.inc
|