簡體   English   中英

服務器崩潰后如何提交XA事務

[英]How to commit a XA transaction after server crashed

我在Mint 18上使用MySQL 5.7.19-0ubuntu0.16.04.1,在准備XA事務時發現,然后服務器崩潰了。 服務重啟后,我無法再進行交易了。 它仍然鎖着桌子。

mysql> xa start'1';

mysql> xa結尾'1';

mysq> xa准備'1';

須藤killall -9 mysqld

sudo服務啟動mysqld

mysql> xa commit'1';

錯誤1399(XAE07):XAER_RMFAIL:當全局事務處於NON-EXISTING狀態時,無法執行該命令

mysql> xa start'1';

錯誤1440(XAE08):XAER_DUPID:XID已存在

bug71352的情況與此類似,但我的版本相距甚遠。 我錯過了什么嗎?

我無法重現該問題:

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)

xa啟動必須失敗,這是預期的,這是未決的XA事務。 您需要先進行xa恢復。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM