[MDEV-25616] Binlog event for XA COMMIT is generated without matching XA START, replication aborts Created: 2021-05-07  Updated: 2023-10-11  Resolved: 2022-10-25

Status: Closed
Project: MariaDB Server
Component/s: Replication, XA
Affects Version/s: 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Andrei Elkin
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Relates
relates to MDEV-742 LP:803649 - Xa recovery failed on cli... Closed
relates to MDEV-29819 Shutdown unexpectedly executes XA ROL... Open
relates to MDEV-31830 Standalone XA COMMIT Binlogged on Rep... Open
relates to MDEV-23868 Replication stops while using XA with... Confirmed

 Description   

--source include/master-slave.inc
 
CREATE TABLE t1 (a INT PRIMARY KEY);
 
XA BEGIN 'x';
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (1),(1);
XA END 'x';
XA PREPARE 'x';
XA COMMIT 'x';
 
--sync_slave_with_master
 
# Cleanup
--connection master
DROP TABLE t1;
--source include/rpl_end.inc

Binlog contains this:

10.5 d44a10f4

master-bin.000001	285	Binlog_checkpoint	1	329	master-bin.000001
master-bin.000001	329	Gtid	1	371	GTID 0-1-1
master-bin.000001	371	Query	1	473	use `test`; CREATE TABLE t1 (a INT PRIMARY KEY)
master-bin.000001	473	Gtid	1	515	BEGIN GTID 0-1-2
master-bin.000001	515	Query	1	611	use `test`; INSERT INTO t1 VALUES (1),(1)
master-bin.000001	611	Query	1	684	COMMIT
master-bin.000001	684	Gtid	1	727	GTID 0-1-3
master-bin.000001	727	Query	1	815	XA COMMIT X'78',X'',1

So, slave SQL thread aborts with

Last_SQL_Errno	1397
Last_SQL_Error	Error 'XAER_NOTA: Unknown XID' on query. Default database: 'test'. Query: 'XA COMMIT X'78',X'',1'

Reproducible on 10.5-10.6, with any binlog format and both transactional and non-transactional engines.
Naturally, with row format the INSERT part is different, and with InnoDB it is not written at all, but the orphan XA COMMIT is still added to the binary log and causes the replication failure.
Not reproducible on 10.4, no generated XA COMMIT there.



 Comments   
Comment by Alice Sherepa [ 2021-06-08 ]

not reproducible with InnoDB + statement format combination

Comment by Brandon Nesterenko [ 2022-09-06 ]

Hi Andrei!

This is ready for review: PR-2260.

Comment by Brandon Nesterenko [ 2022-09-21 ]

Hey Andrei! This is ready for another round of review. PR-2260 for reference.

Comment by Andrei Elkin [ 2022-10-18 ]

The current review round is over. The issue of the errored-out trx engine statement
still needs addressing. I am taking over for that. A commit to the PR is being developed/tested.
ETA to complete with it tomorrow afternoon.

Generated at Thu Feb 08 09:39:02 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.