mysql的XA事务恢复过程详解
更新时间:2012年11月13日 10:21:46 作者:
XA事务支持限于InnoDB存储引擎,本文将详细介绍mysql的XA事务恢复过程
mysql数据库开机报错:
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
100224 12:24:20 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Transaction 0 4497755 was in the XA prepared state.
InnoDB: Transaction 0 4468551 was in the XA prepared state.
InnoDB: Transaction 0 4468140 was in the XA prepared state.
InnoDB: 3 transaction(s) which must be rolled back or cleaned up
InnoDB: in total 0 row operations to undo
InnoDB: Trx id counter is 0 5312768
InnoDB: Starting in background the rollback of uncommitted transactions
100224 12:24:20 InnoDB: Rollback of non-prepared transactions completed
100224 12:24:20 InnoDB: Started; log sequence number 0 3805002509
100224 12:24:20 InnoDB: Starting recovery for XA transactions...
100224 12:24:20 InnoDB: Transaction 0 4497755 in prepared state after recovery
100224 12:24:20 InnoDB: Transaction contains changes to 8 rows
100224 12:24:20 InnoDB: Transaction 0 4468551 in prepared state after recovery
100224 12:24:20 InnoDB: Transaction contains changes to 1 rows
100224 12:24:20 InnoDB: Transaction 0 4468140 in prepared state after recovery
100224 12:24:20 InnoDB: Transaction contains changes to 1 rows
100224 12:24:20 InnoDB: 3 transactions in prepared state after recovery
100224 12:24:20 [Note] Found 3 prepared transaction(s) in InnoDB
100224 12:24:20 [Warning] Found 3 prepared XA transactions
100224 12:24:20 [Note] Event Scheduler: Loaded 0 events
100224 12:24:20 [Note] /opt/mysql/bin/mysqld: ready for connections.
Version: '5.1.39' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server (GPL)
意味着有三个XA的事务没有提交或回滚。
登录到mysql
mysql> xa recover;
+----------+--------------+--------------+------------------------------------------------------------+
| formatID | gtrid_length | bqual_length | data |
+----------+--------------+--------------+------------------------------------------------------------+
| 131075 | 30 | 28 | 1-7f000001:bae5:4b6928eb:f06397f000001:bae5:4b6928eb:f0650 |
| 131075 | 30 | 28 | 1-7f000001:bae5:4b6928eb:fb5c37f000001:bae5:4b6928eb:fb5cd |
| 131075 | 30 | 28 | 1-7f000001:bae5:4b6928eb:f03ea7f000001:bae5:4b6928eb:f0400 |
+----------+--------------+--------------+------------------------------------------------------------+
数据表示信息如下:
formatIDis the formatIDpart of the transaction xid
gtrid_lengthis the length in bytes of the gtridpart of the xid
bqual_lengthis the length in bytes of the bqualpart of the xid
datais the concatenation of the gtridand bqualparts of the xid
这是三个XA事务的信息,准备直接回滚。
mysql> xa rollback '1-7f000001:bae5:4b6928eb:fb5c3','7f000001:bae5:4b6928eb:fb5cd',131075;
Query OK, 0 rows affected (0.41 sec)
再启动就正常了。
MySQL XA
I.5. 对XA事务的限制
XA事务支持限于InnoDB存储引擎。
MySQL XA实施是针对外部XA的,其中,MySQL服务器作为资源管理器,而客户端程序作为事务管理器。未实施“内部XA”。这样,就允许MySQL服务器内的单独存储引擎作为RM(资源管理器),而服务器本身作为TM(事务管理器)。处理包含1个以上存储引擎的XA事务时,需要内部XA。内部XA的实施是不完整的,这是因为,它要求存储引擎在表处理程序层面上支持两阶段提交,目前仅对InnoDB实现了该特性。
对于XA START,不支持JOIN和RESUME子句。
对于XA END,不支持SUSPEND [FOR MIGRATE]子句。
在全局事务内,对于每个XA事务,xid值的bqual部分应是不同的,该要求是对当前MySQL XA实施的限制。它不是XA规范的组成部分。
如果XA事务达到PREPARED状态而且MySQL服务器宕机,当服务器重启后,能够继续处理事务。就像原本应当的那样。但是,如果客户端连接中止而服务器继续运行,服务器将回滚任何未完成的XA事务,即使该事务已达到PREPARED状态也同样。它应能提交或回滚PREPARED XA事务,但在不更改二进制日志机制的情况下不能这样。
相关文章
本来配置可以使用的mysql主从库同步的数据库,突然出现无法同步的情况。那么大家可以参考下面的方法解决下。2011-08-08
这篇文章主要介绍了CentOS 6.6 源码编译安装MySQL 5.7.18教程详解,需要的朋友可以参考下2017-07-07
这篇文章主要介绍了MySQL中row_number的实现过程,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-10-10
这篇文章主要介绍了MySQL中数据类型的验证 的相关资料,需要的朋友可以参考下2016-04-04
这篇文章给大家汇总介绍了Mysql中新建用户及授权的方法,首先介绍的是作者自己的项目经历,后面附上了参考文章,希望能对大家学习mysql有所帮助。2016-07-07
这篇文章主要介绍了Centos中彻底删除Mysql(rpm、yum安装的情况),本文直接给出操作代码,需要的朋友可以参考下2015-02-02
这篇文章主要介绍了MySQL prepare的相关内容,包括prepare的产生,在服务器端的执行过程,以及jdbc对prepare的处理以及相关测试,需要的朋友可以了解下。希望对大家有所帮助。2017-09-09
这篇文章主要介绍了Windows 64 位 mysql 5.7以上版本包解压中没有data目录和my-default.ini及服务无法启动的快速解决办法(问题小结),需要的朋友可以参考下2018-03-03
这篇文章主要介绍了mysql默认编码为UTF-8 通过修改my.ini实现方法的相关资料,为了防止出现乱码,Latin1是不支持汉字的,所以要将其改为UTF-8或GBK,需要的朋友可以参考下2017-01-01
这篇文章主要介绍了mysql数据库设置utf-8编码的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-08-08
最新评论