Atomikos的使用过程中要注意的事
在使用Atomikos过程中遇到的一些问题,以作记录:
MySQL does not support TMJOIN
MySQL does not allow for joining an existing XA transaction branch, as mentioned here:http://dev.mysql.com/doc/refman/5.0/en/xa-restrictions.html - the consequence is that one transaction accessing the same MySQL multiple times can run into problems like this:
A possible workaround might be to try and start TransactionsEssentials with the parametercom.atomikos.icatch.serial_jta_transactions set to false.
com.atomikos.icatch.serial_jta_transactions=false
Also, make sure to set the following property on the MySQL datasource:
pinGlobalTxToPhysicalConnection="true"
以上是Atomikos官方关于Mysql bug的一些说明,解决这个问题按照官方说明,我们可以在jta.properties或者transactions.properties里面添加com.atomikos.icatch.serial_jta_transactions=false这么一段,可能我姿势不正确,没起作用。第二种方法是在Mysql的XADataSource的pinGlobalTxToPhysicalConnection设置为true,这可难办了,我使用的是druid的数据源,好像没有pinGlobalTxToPhysicalConnection这个的属性吧?苦恼了一段时间,查了一些资料都没有发现解决办法,突然灵机一动,试一下在url后缀加上这段东西,没想到真行了。
jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&pinGlobalTxToPhysicalConnection=true
MyBatis不能回滚事务?
2016-10-24 11:07:04,458 INFO [com.atomikos.datasource.xa.XAResourceTransaction] - XAResource.end ( 31302E3232382E37352E3132352E746D30303030313030303134:31302E3232382E37352E3132352E746D31 , XAResource.TMSUCCESS ) on resource apikore represented by XAResource instance [email protected]e2
2016-10-24 11:07:04,462 INFO [com.atomikos.datasource.xa.XAResourceTransaction] - XAResource.rollback ( 31302E3232382E37352E3132352E746D30303030313030303134:31302E3232382E37352E3132352E746D31 ) on resource apikore represented by XAResource instance [email protected]e2
2016-10-24 11:07:04,466 INFO [com.atomikos.icatch.imp.CompositeTransactionImp] - rollback() done of transaction 127.0.0.1.tm0000100014
检查一下控制台是否有着段输出,如果有,那么应该是回滚成功的。如果你断点spring的TransactionManager确定事务应经启用的情况下,出错了却没有回滚,请检查一下,事务设置是否带有rollback-for="Exception"
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"/>
Connection pool exhausted - try increasing 'maxPoolSize'
错误:
[ERROR][-- ::,][org.hibernate.engine.jdbc.spi.SqlExceptionHelper]Connection pool exhausted - try increasing 'maxPoolSize' and/or 'borrowConnectionTimeout' on the DataSourceBean.
[ERROR][-- ::,][org.apache.struts2.dispatcher.Dispatcher]Exception occurred during processing request: Could not open connection
在AtomikosDataSourceBean配置添加如下代码:
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="borrowConnectionTimeout" value="60" />
Error in recovery
错误:
[ERROR][-- ::,][com.atomikos.recovery.imp.CachedRepository]Corrupted log file - restart JVM
com.atomikos.recovery.LogReadException: java.lang.ArrayIndexOutOfBoundsException:
at com.atomikos.recovery.imp.FileSystemRepository.getAllCoordinatorLogEntries(FileSystemRepository.java:)
at com.atomikos.recovery.imp.CachedRepository.init(CachedRepository.java:)
at com.atomikos.icatch.provider.imp.AssemblerImp.createCoordinatorLogEntryRepository(AssemblerImp.java:)
at com.atomikos.icatch.provider.imp.AssemblerImp.assembleTransactionService(AssemblerImp.java:)
at com.atomikos.icatch.)
at com.atomikos.icatch.)
at com.atomikos.icatch.jta.UserTransactionManager.startupTransactionService(UserTransactionManager.java:)
at com.atomikos.icatch.jta.UserTransactionManager.initializeTransactionManagerSingleton(UserTransactionManager.java:)
at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:)
at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
atomikos版本升级到4.0.4解决。
后续若有发现问题,再行添加。
转:https://www.bbsmax.com/A/x9J2LXKd6o/