strange transaction rollback error

I am getting the following stack in the log, as near as I can tell, apparently indicating an issue the transaction surrounding the snapshot generation. However, when I inspect Mongo, all data appears to have been persisted (both events and snapshots). Here is the stack:

5-04-26 12:54:36,846 [pool-1-thread-1] DEBUG - Notifying listeners of transaction commit request
2015-04-26 12:54:36,846 [pool-1-thread-1] DEBUG - Notifying listener [org.axonframework.eventsourcing.EventSourcingRepository$ConflictResolvingListener] of upcoming transaction commit
2015-04-26 12:54:36,846 [pool-1-thread-1] DEBUG - Notifying listener [org.axonframework.repository.LockingRepository$LockCleaningListener] of upcoming transaction commit
2015-04-26 12:54:36,846 [pool-1-thread-1] DEBUG - Notifying listener [org.axonframework.eventsourcing.EventCountSnapshotterTrigger$SnapshotTriggeringListener] of upcoming transaction commit
2015-04-26 12:54:36,846 [pool-1-thread-1] DEBUG - Listeners successfully notified
2015-04-26 12:54:36,847 [pool-1-thread-1] WARN com.arjuna.ats.arjuna - ARJUNA012077: Abort called on already aborted atomic action 0:ffff7f000001:c732:553d422b:3
2015-04-26 12:54:36,852 [pool-1-thread-1] DEBUG - An error occurred while committing this UnitOfWork. Performing rollback…
org.springframework.transaction.UnexpectedRollbackException: JTA transaction already rolled back (probably due to a timeout)
at org.springframework.transaction.jta.JtaTransactionManager.doCommit(JtaTransactionManager.java:1019) ~[spring-tx-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757) ~[spring-tx-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726) ~[spring-tx-4.1.4.RELEASE.jar:4.1.4.RELEASE]
at org.axonframework.unitofwork.SpringTransactionManager.commitTransaction(SpringTransactionManager.java:73) ~[axon-core-2.4.jar:2.4]
at org.axonframework.unitofwork.SpringTransactionManager.commitTransaction(SpringTransactionManager.java:32) ~[axon-core-2.4.jar:2.4]
at org.axonframework.unitofwork.DefaultUnitOfWork.doCommit(DefaultUnitOfWork.java:145) ~[axon-core-2.4.jar:2.4]
at org.axonframework.unitofwork.NestableUnitOfWork.commit(NestableUnitOfWork.java:59) ~[axon-core-2.4.jar:2.4]
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:137) [axon-core-2.4.jar:2.4]
at org.axonframework.commandhandling.SimpleCommandBus.doDispatch(SimpleCommandBus.java:103) [axon-core-2.4.jar:2.4]
at org.axonframework.commandhandling.AsynchronousCommandBus.access$001(AsynchronousCommandBus.java:40) [axon-core-2.4.jar:2.4]
at org.axonframework.commandhandling.AsynchronousCommandBus$DispatchCommand.run(AsynchronousCommandBus.java:94) [axon-core-2.4.jar:2.4]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_75]

And here is the relevant section of the Spring configuration:

${db.events.name} domainEvents snapshotEvents

<axon:snapshotter id=“axonSnapshotter”
event-store=“axonEventStore”
executor=“axonExecutor”
transaction-manager=“transactionManager”/>

${jta.defaultTimeout} ${jta.objectStoreDir} ${jta.objectStoreDir}

<tx:annotation-driven transaction-manager=“transactionManager”/>

I’ve set the transaction default timeout to 900 sec (in an external property file). Has anyone encountered anything like this?

Michael

Hi Michael,

apparently, some component along the line decides that the current transaction needs to be rolled back. There is a “rollbackOnly” flag on the transaction object. You’ll have to figure out which components sets it to “true”.

As far as I know (and this may be based on outdated information), MongoDB doesn’t support transactions. Therefore, all data will be persisted to Mongo, regardless of the result of the surrounding transaction.

Cheers,

Allard

Thanks, Allard. I found the problem.

First, you are right. I had a transaction manager set for the snapshotter, and that clearly is unnecessary in my case, since it’s persisting to Mongo.

But the problem was actually that the transaction was timing out due to a misconfiguration of the Spring PlatformTransactionManager. I had thought that setting the default timeout in the system properties was enough, but apparently, I need to do this:

<bean id=“transactionManager” class=“org.springframework.transaction.jta.JtaTransactionManager”
p:defaultTimeout="${jta.defaultTimeout}"
p:transactionManager-ref=“arjunaTransactionManager”
p:userTransaction-ref=“arjunaUserTransaction”
/>

Obviously, nothing to do with Axiom, but hopefully will help someone else out there.

Michael