gpt4 book ai didi

mysql - 服务器崩溃后如何提交 XA 事务

转载 作者:行者123 更新时间:2023-11-29 10:40:39 28 4
gpt4 key购买 nike

我在 Mint 18 上使用 MySQL 5.7.19-0ubuntu0.16.04.1。我发现当我准备 XA 事务时,然后服务器崩溃了。服务重启后,我就不能再碰交易了。它仍然锁定了 table 。

mysql> xa start '1';

mysql> xa end '1';

mysq> xa prepare '1';

sudo killall -9 mysqld

sudo service start mysqld

mysql> xa commit '1';

ERROR 1399 (XAE07): XAER_RMFAIL: The command cannot be executed when global transaction is in the NON-EXISTING state

mysql> xa start '1';

ERROR 1440 (XAE08): XAER_DUPID: The XID already exists

情况与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)

关于mysql - 服务器崩溃后如何提交 XA 事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45549713/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com