Bug #98616 | XA PREPARE/XA COMMIT/XA ROLLBACK lost if mysql crash just after binlog flush | ||
---|---|---|---|
Submitted: | 15 Feb 2020 15:20 | Modified: | 22 Feb 2020 7:20 |
Reporter: | dennis gao | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: XA transactions | Severity: | S3 (Non-critical) |
Version: | 5.7.29 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[15 Feb 2020 15:20]
dennis gao
[15 Feb 2020 15:52]
dennis gao
Patch to fix these bugs.
Attachment: xa_recover_bugs_for_prepare_commit_rollback-v3.diff (text/x-patch), 28.36 KiB.
[15 Feb 2020 15:53]
dennis gao
The patch is developed on mysql 5.7.25, but can be patched on 5.7.29 and work. The mysql-test test case will be added later.
[16 Feb 2020 16:26]
dennis gao
Patch with test case file.
Attachment: xa_recover_bugs_for_prepare_commit_rollback-v5.diff (text/x-patch), 28.47 KiB.
[16 Feb 2020 16:31]
dennis gao
Plz ignore the previous patch, and check this one for test case file.
Attachment: xa_recover_bugs_for_prepare_commit_rollback-v6.diff (text/x-patch), 38.29 KiB.
[17 Feb 2020 17:15]
MySQL Verification Team
Hi Mr. gao, Thank you for your bug report. I have repeated the behaviour. However, I am in doubt whether this is intended behaviour or not. If it is intended behaviour, then your report would constitute a feature request. I am going to leave that decision to the team in charge of XA transactions. Verified as reported.
[21 Feb 2020 5:05]
MySQL Verification Team
Hello Dennis gao , Thank you very much for your patch contribution, we appreciate it! In order for us to continue the process of reviewing your contribution to MySQL, please send us a signed copy of the Oracle Contributor Agreement (OCA) as outlined in http://www.oracle.com/technetwork/community/oca-486395.html Signing an OCA needs to be done only once and it's valid for all other Oracle governed Open Source projects as well. Getting a signed/approved OCA on file will help us facilitate your contribution - this one, and others in the future. Please let me know, if you have any questions. Thank you for your interest in MySQL. regards, Umesh
[22 Feb 2020 7:20]
dennis gao
Hello Umesh Shastry, Thanks for the response. I have sent the signed OCA application to oracle-ca_us@oracle.com, and waiting for the approval. regards, dennis gao
[22 Feb 2020 7:53]
MySQL Verification Team
Thank you Dennis gao. regards, Umesh
[22 Feb 2020 13:45]
MySQL Verification Team
Bug #98709 marked as duplicate of this one
[5 Mar 2020 11:36]
dennis GAO
The patch after the approved of OCA
Attachment: xa_recover_bugs_for_prepare_commit_rollback-v7.diff (text/x-patch), 38.49 KiB.
[5 Mar 2020 13:51]
MySQL Verification Team
Thank you Mr. Gao !!!!!
[7 Mar 2020 5:25]
dennis GAO
Fix some mistake
Attachment: xa_recover_bugs_for_prepare_commit_rollback-v8.diff (text/x-patch), 38.87 KiB.
[7 Mar 2020 5:31]
dennis GAO
adding the patch as contribution (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: xa_recover_bugs_for_prepare_commit_rollback-v8.diff (text/x-patch), 38.87 KiB.
[9 Mar 2020 13:01]
MySQL Verification Team
Thank you Mr. gao.
[24 Nov 2020 9:27]
Nico Liu
Hi Mr.Gao. I am glad to view your patch. But I have two questions I'd like to ask you. 1. in trx_set_undo_xid_for_prepare_for_mysql TrxInInnoDB trx_in_innodb(trx, true); trx->in_innodb will be set to TRX_FORCE_ROLLBACK_DISABLE What is the purpose of this? Or is it necessary? 2. in trx_recover_for_mysql if (trx_state_eq(trx, TRX_STATE_PREPARED) || (trx->xid && !trx->xid->get_my_xid())) { in some cases, the xid of a common transaction is not NULL, I think we can change it to if (trx_state_eq(trx, TRX_STATE_PREPARED) || (trx->xid && !trx->xid->get_my_xid() && !trx->xid->is_null())){ These are my two questions. I look forward to your reply. Best Regards.
[24 Nov 2020 10:34]
dennis GAO
Hello Nico Liu, For "trx->in_innodb will be set to TRX_FORCE_ROLLBACK_DISABLE", I think it is not necessary, trx_set_undo_xid_for_prepare_for_mysql func is before doing prepare, not the prepare. I think the transaction still can be rollback in this point. For the second one, I think you are correct. "!trx->xid->is_null()" should be added. regards, dennis gao
[24 Nov 2020 10:36]
dennis GAO
Postfix for the preview patch "xa_recover_bugs_for_prepare_commit_rollback-v8.diff". (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: postfix-xa_recover_bugs_for_prepare_commit_rollback.diff (text/x-patch), 1.39 KiB.
[24 Nov 2020 10:37]
dennis GAO
postfix-xa_recover_bugs_for_prepare_commit_rollback.diff will fix one bug of preview patch: If a trx in trx_sys->rw_trx_list has been rollbacked in trx_rollback_resurrected during start-up recover due to trx->xid->get_gtrid_length()==0, xarecover_handlerton should skip this trx rather than do hton->rollback_by_xid, which will lead mysql crash.
[24 Nov 2020 13:34]
Nico Liu
Hello Dennis gao , Thanks for your reply. In the previous process, binlog is written before innodb. As a result, the crash safe capability is unavailable. Your patch writes undo before writing binlog, but does not modify subsequent actions in the previous process. As a result, innodb_trx increases. Can the sequence of the previous process be changed? Or what's the idea of your patch? regards, nico Liu.
[25 Nov 2020 15:47]
dennis GAO
Hello Nico Liu, I see your name maybe a Chinese name, maybe you can check my Chinese blog for the problem analysis: http://blog.sina.com.cn/s/blog_4673e6030102zdtd.html So that you will known why need write xid to undo before flush binlog.
[30 Nov 2020 14:39]
MySQL Verification Team
Thank you for your discussion.
[17 Dec 2020 4:45]
nico liu
Hello Dennis gao , I'm sorry to ask you a few more questions. If an active undo is created in the InnoDB and the binlog is rotated during the recovery process, the patch will be degraded and invalid. Active transactions will be rolled back in xareocver. It does not seem to satisfy the rules of group submission. regards, Nico liu