2017-08-07 60 views
0

我在Mint 18上使用MySQL 5.7.19-0ubuntu0.16.04.1。我發現當我準備好XA事務時,然後服務器崩潰了。服務重新啓動後,我無法再觸碰交易。它仍然鎖定了桌子。如何在服務器崩潰後提交XA事務

mysql> xa start'1';

mysql> xa end'1';

mysq> xa準備'1';

須藤killall -9的mysqld

須藤服務啓動mysqld

的MySQL> XA犯 '1';

ERROR 1399(XAE07):XAER_RMFAIL:當全局事務是在不存在的狀態

的MySQL> XA啓動 '1' 的命令不能被執行;

ERROR 1440(XAE08):XAER_DUPID:該XID已經存在

的情況與bug71352相似,但我的版本是那麼的遙遠。 我錯過了什麼?

回答

1

我不能重現該問題:

mysql> \! lsb_release --description 
Description: Linux Mint 18.2 Sonya 

mysql> SELECT VERSION(); 
+-----------+ 
| VERSION() | 
+-----------+ 
| 5.7.19 | 
+-----------+ 
1 row in set (0.00 sec) 

mysql> DROP TABLE IF EXISTS `t`; 
Query OK, 0 rows affected, 1 warning (0.00 sec) 

mysql> CREATE TABLE IF NOT EXISTS `t` (
    -> `id` INT 
    ->) ENGINE=InnoDB; 
Query OK, 0 rows affected (0.00 sec) 

mysql> XA START '1'; 
Query OK, 0 rows affected (0.00 sec) 

mysql> INSERT INTO `t` 
    -> VALUES (1); 
Query OK, 1 row affected (0.01 sec) 

mysql> XA END '1'; 
Query OK, 0 rows affected (0.00 sec) 

mysql> XA PREPARE '1'; 
Query OK, 0 rows affected (0.00 sec) 

mysql> XA RECOVER; 
+----------+--------------+--------------+------+ 
| formatID | gtrid_length | bqual_length | data | 
+----------+--------------+--------------+------+ 
|  1 |   1 |   0 | 1 | 
+----------+--------------+--------------+------+ 
1 row in set (0.00 sec) 

-- Killed mysqld from other session 

mysql> \! service mysql status | grep 'Active' 
    Active: inactive (dead) since 33s ago 

-- Restared mysqld from other session 

mysql> \! service mysql status | grep 'Active' 
    Active: active (running) since 3s ago 

mysql> XA RECOVER; 
ERROR 2006 (HY000): MySQL server has gone away 
No connection. Trying to reconnect... 
Connection id: 
Current database: 

+----------+--------------+--------------+------+ 
| formatID | gtrid_length | bqual_length | data | 
+----------+--------------+--------------+------+ 
|  1 |   1 |   0 | 1 | 
+----------+--------------+--------------+------+ 
1 row in set (0.02 sec) 

mysql> SELECT `id` FROM `t`; 
Empty set (0.00 sec) 

mysql> XA START '1'; 
ERROR 1440 (XAE08): XAER_DUPID: The XID already exists 

mysql> XA COMMIT '1'; 
Query OK, 0 rows affected (0.00 sec) 

mysql> SELECT `id` FROM `t`; 
+------+ 
| id | 
+------+ 
| 1 | 
+------+ 
1 row in set (0.00 sec) 
0

的XA開始一定會失敗,這是預期的,這是懸而未決的XA事務。你需要先做一次xa恢復。