Druid多数据源与Atomikos分布式事回滚不起做用

在研究分布式事务的时候,模拟多数据库失败统一回滚,结果日志输出看到了 start prepareStatement end rollback,就是数据没有回滚,日志如下:

2021-08-20 22:30:32.660  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.BaseTransactionManager    : createCompositeTransaction ( 10000 ): created new ROOT transaction with id 169.254.43.181.tm0000400025
2021-08-20 22:30:32.660  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'financeDataSource': getConnection ( null )...
2021-08-20 22:30:32.660  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'financeDataSource': init...
2021-08-20 22:30:32.660  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@695fa8c7: calling getAutoCommit...
2021-08-20 22:30:32.661  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : addParticipant ( XAResourceTransaction: 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3132 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.661  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.start ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3132 , XAResource.TMNOFLAGS ) on resource financeDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@3b8c79d9
2021-08-20 22:30:32.661  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@305953b4 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.661  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@695fa8c7: calling prepareStatement(UPDATE account_amount SET amount=amount + ? WHERE user_account_id=?)...
2021-08-20 22:30:32.700  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@305953b4 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.701  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@695fa8c7: calling prepareStatement(UPDATE account_amount SET amount=amount + ? WHERE user_account_id=?)...
2021-08-20 22:30:32.725  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'orderDataSource': getConnection ( null )...
2021-08-20 22:30:32.725  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'orderDataSource': init...
2021-08-20 22:30:32.725  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1b25de8b: calling getAutoCommit...
2021-08-20 22:30:32.725  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : addParticipant ( XAResourceTransaction: 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3133 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.725  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.start ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3133 , XAResource.TMNOFLAGS ) on resource orderDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1ccd6885
2021-08-20 22:30:32.727  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@305953b4 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.727  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1b25de8b: calling prepareStatement(INSERT INTO refill_order(order_no,user_account_id,business_account_id,business_name,amount,title,type,status,pay_type,refill_comment,refill_phone_number,refill_data,credit,modified_time) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,SYSDATE()))...
2021-08-20 22:30:32.728  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'lotteryDataSource': getConnection ( null )...
2021-08-20 22:30:32.728  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'lotteryDataSource': init...
2021-08-20 22:30:32.729  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@10055baa: calling getAutoCommit...
2021-08-20 22:30:32.729  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : addParticipant ( XAResourceTransaction: 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3134 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.729  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.start ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3134 , XAResource.TMNOFLAGS ) on resource lotteryDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1f090c31
2021-08-20 22:30:32.729  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : registerSynchronization ( com.atomikos.jdbc.AtomikosConnectionProxy$JdbcRequeueSynchronization@305953b4 ) for transaction 169.254.43.181.tm0000400025
2021-08-20 22:30:32.729  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@10055baa: calling prepareStatement(UPDATE lottery_draw SET lottery_draw_count = lottery_draw_count + 1 ,modified_time=SYSDATE()WHERE user_account_id=?)...
2021-08-20 22:30:32.730  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'creditDataSource': getConnection ( null )...
2021-08-20 22:30:32.730  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AbstractDataSourceBean   : AtomikosDataSoureBean 'creditDataSource': init...
2021-08-20 22:30:32.731  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@f4a7f05: calling getAutoCommit...
2021-08-20 22:30:32.736  WARN 6664 --- [nio-8080-exec-1] c.a.jdbc.JdbcConnectionProxyHelper       : Error delegating 'getAutoCommit' call
2021-08-20 22:30:32.736  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@f4a7f05: calling rollback...
2021-08-20 22:30:32.736  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@695fa8c7: close()...
2021-08-20 22:30:32.736  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.end ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3132 , XAResource.TMSUCCESS ) on resource financeDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@3b8c79d9
2021-08-20 22:30:32.737  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@1b25de8b: close()...
2021-08-20 22:30:32.737  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.end ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3133 , XAResource.TMSUCCESS ) on resource orderDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1ccd6885
2021-08-20 22:30:32.738  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@10055baa: close()...
2021-08-20 22:30:32.738  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.end ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3134 , XAResource.TMSUCCESS ) on resource lotteryDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1f090c31
2021-08-20 22:30:32.738  INFO 6664 --- [nio-8080-exec-1] c.atomikos.jdbc.AtomikosConnectionProxy  : atomikos connection proxy for com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@f4a7f05: close()...
2021-08-20 22:30:32.738  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.rollback ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3132 ) on resource financeDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@3b8c79d9
2021-08-20 22:30:32.739  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.rollback ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3133 ) on resource orderDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1ccd6885
2021-08-20 22:30:32.784  INFO 6664 --- [nio-8080-exec-1] c.a.datasource.xa.XAResourceTransaction  : XAResource.rollback ( 3136392E3235342E34332E3138312E746D30303030343030303235:3136392E3235342E34332E3138312E746D3134 ) on resource lotteryDataSource represented by XAResource instance com.mysql.jdbc.jdbc2.optional.MysqlXAConnection@1f090c31
2021-08-20 22:30:32.817  INFO 6664 --- [nio-8080-exec-1] c.a.icatch.imp.CompositeTransactionImp   : rollback() done of transaction 169.254.43.181.tm0000400025

结果百度了好多,发现还是不行,最后检查了一下表,居然表是用的MyISAM引擎,不支持事务呀,怎么回滚,后面改成InnoDB就好了,真是好坑。

你可能感兴趣的:(Druid多数据源与Atomikos分布式事回滚不起做用)