XA全局事务超时后回滚失败,一直报XAER_RMFAIL
流程: 全局事务超时时间配置为10秒。在A服务上配置了全局事务注解,A服务更新数据库然后调用B服务。B服务更新数据库后休眠15秒,15秒后提交B服务的事务。A、B服务使用同一个数据库实例的多张表。
2022-06-16 21:21:55.612 INFO [rpcDispatch_RMROLE_1_12_16] i.s.c.r.p.c.RmBranchRollbackProcessor - rm handle branch rollback process:xid=10.90.13.27:8091:2549311505400693112,branchId=234461296923190606,branchType=XA,resourceId=jdbc:mysql://192.168.201.120:3306/spring_clond_demo,applicationData=null
2022-06-16 21:21:55.612 INFO [rpcDispatch_RMROLE_1_12_16] io.seata.rm.AbstractRMHandler - Branch Rollbacking: 10.90.13.27:8091:2549311505400693112 234461296923190606 jdbc:mysql://192.168.201.120:3306/spring_clond_demo
2022-06-16 21:21:55.621 INFO [rpcDispatch_RMROLE_1_12_16] i.s.r.d.xa.ResourceManagerXA - 10.90.13.27:8091:2549311505400693112-234461296923190606 rollback failed since XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
com.mysql.cj.jdbc.MysqlXAException: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
at com.mysql.cj.jdbc.MysqlXAConnection.mapXAExceptionFromSQLException(MysqlXAConnection.java:344)
at com.mysql.cj.jdbc.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:329)
at com.mysql.cj.jdbc.MysqlXAConnection.rollback(MysqlXAConnection.java:243)
at io.seata.rm.datasource.xa.ConnectionProxyXA.xaRollback(ConnectionProxyXA.java:141)
at io.seata.rm.datasource.xa.ConnectionProxyXA.xaRollback(ConnectionProxyXA.java:132)
at io.seata.rm.datasource.xa.ResourceManagerXA.finishBranch(ResourceManagerXA.java:115)
at io.seata.rm.datasource.xa.ResourceManagerXA.branchRollback(ResourceManagerXA.java:100)
at io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:125)
at io.seata.rm.AbstractRMHandler$2.execute(AbstractRMHandler.java:67)
at io.seata.rm.AbstractRMHandler$2.execute(AbstractRMHandler.java:63)
at io.seata.core.exception.AbstractExceptionHandler.exceptionHandleTemplate(AbstractExceptionHandler.java:131)
at io.seata.rm.AbstractRMHandler.handle(AbstractRMHandler.java:63)
at io.seata.rm.DefaultRMHandler.handle(DefaultRMHandler.java:68)
at io.seata.core.protocol.transaction.BranchRollbackRequest.handle(BranchRollbackRequest.java:35)
at io.seata.rm.AbstractRMHandler.onRequest(AbstractRMHandler.java:150)
at io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.handleBranchRollback(RmBranchRollbackProcessor.java:63)
at io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:58)
at io.seata.core.rpc.netty.AbstractNettyRemoting.lambda$processMessage$2(AbstractNettyRemoting.java:281)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:762)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:646)
at com.mysql.cj.jdbc.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:323)
... 20 common frames omitted
2022-06-16 21:21:55.621 INFO [rpcDispatch_RMROLE_1_12_16] io.seata.rm.AbstractRMHandler - Branch Rollbacked result: PhaseTwo_RollbackFailed_Retryable
2022-06-16 21:21:56.058 INFO [rpcDispatch_RMROLE_1_13_16] i.s.c.r.p.c.RmBranchRollbackProcessor - rm handle branch rollback process:xid=10.90.13.27:8091:2549311505400693112,branchId=234461296923190606,branchType=XA,resourceId=jdbc:mysql://192.168.201.120:3306/spring_clond_demo,applicationData=null
2022-06-16 21:21:56.058 INFO [rpcDispatch_RMROLE_1_13_16] io.seata.rm.AbstractRMHandler - Branch Rollbacking: 10.90.13.27:8091:2549311505400693112 234461296923190606 jdbc:mysql://192.168.201.120:3306/spring_clond_demo
2022-06-16 21:21:56.065 INFO [rpcDispatch_RMROLE_1_13_16] i.s.r.d.xa.ResourceManagerXA - 10.90.13.27:8091:2549311505400693112-234461296923190606 rollback failed since XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
com.mysql.cj.jdbc.MysqlXAException: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
at com.mysql.cj.jdbc.MysqlXAConnection.mapXAExceptionFromSQLException(MysqlXAConnection.java:344)
at com.mysql.cj.jdbc.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:329)
at com.mysql.cj.jdbc.MysqlXAConnection.rollback(MysqlXAConnection.java:243)
at io.seata.rm.datasource.xa.ConnectionProxyXA.xaRollback(ConnectionProxyXA.java:141)
at io.seata.rm.datasource.xa.ConnectionProxyXA.xaRollback(ConnectionProxyXA.java:132)
at io.seata.rm.datasource.xa.ResourceManagerXA.finishBranch(ResourceManagerXA.java:115)
at io.seata.rm.datasource.xa.ResourceManagerXA.branchRollback(ResourceManagerXA.java:100)
at io.seata.rm.AbstractRMHandler.doBranchRollback(AbstractRMHandler.java:125)
at io.seata.rm.AbstractRMHandler$2.execute(AbstractRMHandler.java:67)
at io.seata.rm.AbstractRMHandler$2.execute(AbstractRMHandler.java:63)
at io.seata.core.exception.AbstractExceptionHandler.exceptionHandleTemplate(AbstractExceptionHandler.java:131)
at io.seata.rm.AbstractRMHandler.handle(AbstractRMHandler.java:63)
at io.seata.rm.DefaultRMHandler.handle(DefaultRMHandler.java:68)
at io.seata.core.protocol.transaction.BranchRollbackRequest.handle(BranchRollbackRequest.java:35)
at io.seata.rm.AbstractRMHandler.onRequest(AbstractRMHandler.java:150)
at io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.handleBranchRollback(RmBranchRollbackProcessor.java:63)
at io.seata.core.rpc.processor.client.RmBranchRollbackProcessor.process(RmBranchRollbackProcessor.java:58)
at io.seata.core.rpc.netty.AbstractNettyRemoting.lambda$processMessage$2(AbstractNettyRemoting.java:281)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.sql.SQLException: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:762)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:646)
at com.mysql.cj.jdbc.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:323)
... 20 common frames omitted
2022-06-16 21:21:56.065 INFO [rpcDispatch_RMROLE_1_13_16] io.seata.rm.AbstractRMHandler - Branch Rollbacked result: PhaseTwo_RollbackFailed_Retryable
有时会在70秒后出现Branch Rollbacked result: PhaseTwo_RollbackFailed_XAER_NOTA_Retryable
,然后回滚成功,多数情况下会一直报错下去。
- JDK version : 1.8
- Seata version: 1.5.1
- OS : Windows
- MySQL: 5.7.30