Atomikos错误准备交易"交易ID"标识符不存在

时间:2018-01-15 18:22:04

标签: spring spring-boot spring-transactions jta atomikos

我有使用Atomikos作为事务管理器的Spring启动应用程序,我看到了这个日志:

  

错误:使用标识符准备的交易" 1096044365_MTcyLjE3LjAuMy50bTAwNDAyMDAwMDE = _MTcyLjE3LjAuMy50bTQwMg =="不存在

连续打印。

在阅读Atomikos文档后,我了解到Atomikos有一些崩溃恢复机制,我遵循了http://fogbugz.atomikos.com/default4343.html?community.6.1918.14,但它没有解决我的问题。

我的问题是:为什么Atomikos会尝试永远清理tx?当没有机会让它进入状态时。

下面是堆栈跟踪:

  

org.postgresql.xa.PGXAException:回滚准备好的事务时出错       在org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:419)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       在com.atomikos.datasource.xa.XAResourceTransaction.rollback(XAResourceTransaction.java:636)〜[transactions-jta-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:70)[transactions-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:83)[transactions-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.Propagator $ PropagatorThread.run(Propagator.java:79)[transactions-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:58)[transactions-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.HeurHazardStateHandler.onTimeout(HeurHazardStateHandler.java:135)[transactions-3.9.3.jar!/:na]       在com.atomikos.icatch.imp.CoordinatorImp.alarm(CoordinatorImp.java:933)[transactions-3.9.3.jar!/:na]       在com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:112)[atomikos-util-3.9.3.jar!/:na]       在com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:99)[atomikos-util-3.9.3.jar!/:na]       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_151]       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_151]       在java.lang.Thread.run(Thread.java:748)[na:1.8.0_151]   引起:org.postgresql.util.PSQLException:错误:准备好的具有标识符的事务" 1096044365_MTcyLjE3LjAuMy50bTAwNDAyMDAwMDE = _MTcyLjE3LjAuMy50bTQwMg =="不存在       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       在org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:302)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       在org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:409)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       ...省略了12个常见帧

如何停止此重试机制

更新到4.0.6后再次发生这种情况

  

2018-01-22 20:42:52.247错误[RequestId:] 1 --- [Atomikos:51] c.a.datasource.xa.XAResourceTransaction:XAResourceTransaction的启发式终止:3137322E31372E302E342E746D313531363637303131363034343030383435:3137322E31372E302E342E746D383435状态为HEUR_HAZARD   2018-01-22 20:42:52.247 ERROR [RequestId:] 1 --- [Atomikos:51] com.atomikos.icatch.imp.CoordinatorImp:协调器172.17.0.4.tm151667011604400845的本地启发式终止,状态为HEUR_HAZARD   2018-01-22 20:42:52.247 ERROR [RequestId:] 1 --- [Atomikos:51] com.atomikos.publish.EventPublisher:Transaction 172.17.0.4.tm151667011604400845 corrupted - check https://www.atomikos.com/Documentation/HowToHandleHeuristics了解更多   2018-01-22 20:42:52.420 WARN [RequestId:] 1 --- [Atomikos:51] cadatasource.xa.XAResourceTransaction:XA资源' postgres':XID的回滚' 3137322E31372E302E342E746D313531363637303131363034343030383435 :3137322E31372E302E342E746D383435'提升-3:XA资源检测到内部错误

     

org.postgresql.xa.PGXAException:回滚准备好的事务时出错       在org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:419)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       在com.atomikos.datasource.xa.XAResourceTransaction.rollback(XAResourceTransaction.java:460)〜[transactions-jta-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:47)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.RollbackMessage.send(RollbackMessage.java:20)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.PropagationMessage.submit(PropagationMessage.java:67)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.Propagator $ PropagatorThread.run(Propagator.java:63)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.Propagator.submitPropagationMessage(Propagator.java:42)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.HeurHazardStateHandler.onTimeout(HeurHazardStateHandler.java:75)[transactions-4.0.6.jar!/:na]       在com.atomikos.icatch.imp.CoordinatorImp.alarm(CoordinatorImp.java:650)[transactions-4.0.6.jar!/:na]       在com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:95)[atomikos-util-4.0.6.jar!/:na]       在com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:82)[atomikos-util-4.0.6.jar!/:na]       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_151]       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_151]       在java.lang.Thread.run(Thread.java:748)[na:1.8.0_151]   引起:org.postgresql.util.PSQLException:错误:准备好的具有标识符的事务" 1096044365_MTcyLjE3LjAuNC50bTE1MTY2NzAxMTYwNDQwMDg0NQ == _ MTcyLjE3LjAuNC50bTg0NQ =="不存在       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       在org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)~ [postgresql-9.1-901-1.jdbc4.jar!/:na]       at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:302)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       在org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:409)〜[postgresql-9.1-901-1.jdbc4.jar!/:na]       ...省略了13个常见帧

2 个答案:

答案 0 :(得分:0)

这看起来像是在TransactionsEssentials 4.0.6

中修复的错误

答案 1 :(得分:0)

在深入研究Atomikos源代码并完成堆栈跟踪之后。 以下是我在CoordinatorImp.java中对警报方法所做的更改(在Atomikos源代码中),这解决了我的问题。

public void alarm ( AlarmTimer timer )
{
   try {
        boolean isHeuristic = stateHandler_ instanceof 
          HeurHazardStateHandler 
|| stateHandler_ instanceof HeurAbortedStateHandler
                                  || stateHandler_ instanceof HeurCommittedStateHandler || stateHandler_ instanceof HeurMixedStateHandler;
    if (!(isHeuristic)) {
     stateHandler_.onTimeout ();
    }
    } catch ( Exception e ) {
       LOGGER.logWarning( "Exception on timeout of coordinator " + root_ , e );
    }
   }