Bug #99045 | deadlock during XA cause slave SQL thread XAER_RMFAIL error | ||
---|---|---|---|
Submitted: | 24 Mar 2020 3:30 | Modified: | 26 Mar 2020 6:36 |
Reporter: | Jie Zhou | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: XA transactions | Severity: | S2 (Serious) |
Version: | 5.7, 8.0, 5.7.29 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[24 Mar 2020 3:30]
Jie Zhou
[24 Mar 2020 6:34]
MySQL Verification Team
Hello Jie Zhou, Thank you for the report and test case. Verified as described with 5.7.29 build. Thanks, Umesh
[26 Mar 2020 6:36]
Jie Zhou
I did some debug work and find the problem. The deadlock case run into function `trans_rollback_implicit`, it clears OPTION_BEGIN flag. So the subsequent DML fails to know it belongs to XA and starts a new autocommit trx. My suggested fix: --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -450,7 +450,8 @@ bool trans_rollback_implicit(THD *thd) ~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY); DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); res= ha_rollback_trans(thd, true); - thd->variables.option_bits&= ~OPTION_BEGIN; + if (thd->get_transaction()->xid_state()->has_state(XID_STATE::XA_NOTR)) + thd->variables.option_bits&= ~OPTION_BEGIN; thd->get_transaction()->reset_unsafe_rollback_flags( Transaction_ctx::SESSION);
[3 Jun 2021 10:55]
Jay Chu
On MySQL community 5.7.34 -> community 5.7.34 (replica instance), problem still persists.
[21 Feb 2023 16:54]
MySQL Verification Team
Bug #110151 marked as duplicate of this one