Bug #82253 | deadlock xa transaction restarting break the ACID of transaction | ||
---|---|---|---|
Submitted: | 16 Jul 2016 14:21 | Modified: | 27 Jul 2016 2:41 |
Reporter: | dennis gao | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: XA transactions | Severity: | S3 (Non-critical) |
Version: | 5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | xa deadlock |
[16 Jul 2016 14:21]
dennis gao
[25 Jul 2016 15:47]
MySQL Verification Team
Hi! We need all the data and commands that you used in order to attempt to repeat your report. We also require your entire configuration. Best way to provide data is to upload all tables used in the transactions.......... Thanks in advance .....
[25 Jul 2016 15:52]
MySQL Verification Team
Just for your information, if it is only about local transactions, MySQL aborts one of the transactions involved in the deadlock automatically. It can not abort global transaction. That is something that has to be done by DBA, as he / she only knows the precedence in the global transactions. Global transactions are not managed by the SE, but by the client side.
[26 Jul 2016 1:56]
dennis gao
The key problem is that: The global xa transaction is not stopped (rollback), the client can not start a local transaction, but still can do local modification, which is not controlled by the transaction.
[26 Jul 2016 2:40]
dennis gao
Hi all, I rewrite the bug description to make it more readable. The test related tables: mysql> show create table t1; +-------+----------------------------------------------------------------------------------------+ | Table | Create Table | +-------+----------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `c1` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+----------------------------------------------------------------------------------------+ 1 row in set (0.06 sec) mysql> show create table t_xa; +-------+------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------+ | t_xa | CREATE TABLE `t_xa` ( `c1` int(11) NOT NULL, PRIMARY KEY (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+------------------------------------------------------------------------------------------------------------+ 1 row in set (0.05 sec) mysql> select * from t1; Empty set (0.06 sec) mysql> select * from t_xa; +----+ | c1 | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | +----+ 5 rows in set (0.08 sec) Then we open two clients: ---------------------------------------------------------------- client 1 | client 2 mysql>use test; | | mysql>use test; mysql>xa start '1'; | | mysql>xa start '2'; mysql>delete from t_xa where c1=1; | | mysql>delete from t_xa where c1=2; mysql>delete from t_xa where c1=2; | (be blocked) | | mysql>delete from t_xa where c1=1; | (Deadlock found when trying to get lock; try restarting transaction) | mysql>select * from t1; | (empty result) | mysql>insert into t1 values (1); | mysql> xa end '2'; | (XA_RBDEADLOCK: Transaction branch was rolled back: deadlock was detected) | mysql> xa rollback '2'; | mysql> select * from t1; | (value 1 has been inserted.) IMO, after "Deadlock found when trying to get lock; try restarting transaction", mysql should refuse to execute any data modification until the xa transaction is rolled back. It is really confusing now.
[26 Jul 2016 2:43]
dennis gao
mysql conf file
Attachment: my9999.cnf (application/octet-stream, text), 1.08 KiB.
[26 Jul 2016 13:37]
MySQL Verification Team
Hi , I have to write once more a comment that I wrote ... Please, point out at what is the bug, knowing the following: Just for your information, if it is only about local transactions, MySQL aborts one of the transactions involved in the deadlock automatically. It can not abort global transaction. That is something that has to be done by DBA, as he / she only knows the precedence in the global transactions. Global transactions are not managed by the single MySQL server, but by the client program that manages the entire transaction through its interface. Some of our connectors, like Connector/J have all the necessary elements in the interface.
[27 Jul 2016 2:41]
dennis gao
I know it is not a big functional problem. What I want is to adjust the mysql behaviour to make it less confusing and more work as design. Normally, mysql does not allow to start a local transaction if the xa transaction is not finished. For deadlock aborted xa transaction, you still can not use "begin/start transaction", so I think mysql still consider it as a running transaction, and refuse to start a local transaction when the xa transaction is not finished. But for deadlock aborted xa transaction, it allow the local single stmt transaction to be executed before the xa transaction is finished. I think it does not work as design, it break the rule(possible): "does not allow to start a local transaction if the xa transaction is not finished" IMO, the "bug" also means does not work as expected. Anyway, if mysql really design to allow the "local single stmt transaction to be executed before the xa transaction is finished", it is not a bug.