Bug #99205 xa prepare write binlog while execute failed
Submitted: 8 Apr 2020 1:36 Modified: 8 Apr 2020 11:18
Reporter: phoenix Zhang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: XA transactions Severity:S2 (Serious)
Version:8.0.18, 8.0.19 OS:Any
Assigned to: CPU Architecture:Any
Tags: group_replication, xa

[8 Apr 2020 1:36] phoenix Zhang
Description:
In a group_replication cluster (primary-mode=off), when XA PREPARE failed with error ER_XA_RBROLLBACK, it still write binlog, which may lead the group_replication begin replication error.

How to repeat:
build a 2 nodes group_replication with primary-mode=off. then execute as below sequence.

connect node1:
create table t1 (c1 int primary key, c2 int) engine=innodb;
insert into t1 values (1,1);
xa start '1';
delete from t1 where c1=1;

connect node2:
delete from t1 where c1=1;

connect node1:
xa end '1';
xa prepare '1'; /* xa prepare will failed with ER_XA_RBROLLBACK */

connect node2, the status of node2 will be ERROR
select * from performance_schema.replication_group_members;

connect node1, it can find that XA PREPARE in binlog file
show binlog events;
[8 Apr 2020 1:37] phoenix Zhang
i add a test-case about this bug.  run it with command: ./mtr group_replication.gr_xa_prepare_bug --nocheck-testcase

Attachment: gr_xa_prepare_bug.test (application/octet-stream, text), 1.37 KiB.

[8 Apr 2020 10:24] phoenix Zhang
this patch can repeat the problem without group_replicaiton.   run  ./mtr main.xa_prepare_bug --nocheck-testcase

Attachment: xa_prepare_bug.diff (text/x-patch), 1.15 KiB.

[8 Apr 2020 11:18] MySQL Verification Team
Hello phoenix Zhang!

Thank you for the report.

regards,
Umesh