+ -

Some work is done outside global transaction

时间:2006-12-04

来源:gladness

在手机上看
手机扫描阅读
mysql> create table test(a varchar(100))engine=innodb;
Query OK, 0 rows affected (0.08 sec)

mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)

mysql> insert into test values('abc');
Query OK, 1 row affected (0.00 sec)

mysql> xa start '1111';
ERROR 1400 (XAE09): XAER_OUTSIDE: Some work is done outside global transaction

如果set autocommit=0后面紧接着就xa start,是不会报错的。因为此时本地(非XA)事务还未开始。

手册上说:

Within the context of a given client connection, XA transactions and local (non-XA) transactions are mutually exclusive. For example, if XA START has been issued to begin an XA transaction, a local transaction cannot be started until the XA transaction has been committed or rolled back. Conversely, if a local transaction has been started with START TRANSACTION, no XA statements can be used until the transaction has been committed or rolled back.

在一个客户端连接的上下文中,XA事务和本地(非XA)事务是互斥的。例如,如果用XA START开始了一个XA事务,在该事务提交或者回滚前,是不能开始本地事务的(在同一连接中)。相反,如果用START TRANSACTION开始了一个本地事务,在该事务提交或者回滚前,XA相关的语句是不能执行的。

Note that if an XA transaction is in the ACTIVE state, you cannot issue any statements that cause an implicit commit. That would violate the XA contract because you could not roll back the XA transaction. You will receive the following error if you try to execute such a statement:

注意如果一个XA事务处于ACTIVE状态,你不能执行导致隐含提交的语句。那会破坏XA的规矩,因为你会无法回滚XA事务。如果你尝试执行这样一条语句,你会得到下面的错误:

ERROR 1399 (XAE07): XAER_RMFAIL: The command cannot be executed
when global transaction is in the ACTIVE state
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> xa start '2222';
ERROR 1400 (XAE09): XAER_OUTSIDE: Some work is done outside global transaction

热门下载

更多