Bug #86819 XAER_RMFAIL ERROR
Submitted: 24 Jun 2017 5:56 Modified: 27 Apr 2021 12:28
Reporter: JIANYA ZHOU Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: XA transactions Severity:S3 (Non-critical)
Version:5.7.17 OS:Red Hat (Linux 2.6.32-642.13.1.el6.x86_64 #1 SMP Wed Jan 11 20:56:24 UTC 2017 x86_64 x86_64 x86_64 GNU)
Assigned to: CPU Architecture:Any

[24 Jun 2017 5:56] JIANYA ZHOU
Description:
When Using XA transactions, if a dealock occurred on master, It could write incorrect binlog which lead to an Replication XAER_RMFAIL error on slave.
There is a similar bug (Bug #24764800) which was fixed in MysQL5.7.17. But I didn't find anyone reported this bug.

mysql> select @@version;
+------------+
| @@version  |
+------------+
| 5.7.17-log |
+------------+
1 row in set (0.00 sec)

mysql> show global variables like '%bin%format%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.02 sec)

########  Incorrect binlog on master  #########
# at 408745919
SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/;
SET TIMESTAMP=1497047545/*!*/;
XA START X'00000000000000000000ffffc613076f57ff2898593b0eec0003b37c31',X'00000000000000000000ffffc613076f57ff2898593b0eec0003b3800000000500000000',131077 /*!*/;
... SQL STATEMENT ...
COMMIT  -- This is wrong, this should be followed by XA COMMIT 

Repliation Error on slave:
Last_Error: Error 'XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state' on query. Default database: 'test'. Query: 'COMMIT'

How to repeat:
I can't reproduce this because it only happened intermittently when deadlock occurred.
[27 Jun 2017 13:30] MySQL Verification Team
Hi!

We can not verify bug without a repeatable test case. We can fix a bug only when we discover its cause. To discover its cause we need a test case that will always lead to the problem that you described. When we have a test case , we can discover exactly were in the code it happens and why.

Since your problems involve XA transactions, you should also include the info about XA manager that you used, chain of servers that were involved in the XA transaction and on which of the servers, or its slaves, did the problem occur. 

We are eagerly awaiting your response.
[28 Jul 2017 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[27 Apr 2021 2:30] jingbo zhao
You can reference https://bugs.mysql.com/bug.php?id=83295