ShardingSphere Narayana XA 事务不回滚问题定位
ShardingSphere Narayana XA 事务不回滚问题定位
问题背景
用户反馈,在使用 ShardingSphere + Narayana 执行 XA 事务时,发生报错:java.sql.SQLException: javax.transaction.RollbackException: TransactionImple.enlistResource - ARJUNA016064: The transaction is in an invalid state!。
这个报错的含义简单来说就是这个事务已经在其他地方被标记成只可回滚了,不能再进行后续其他的操作。报错信息如下:
Caused by: java.sql.SQLException: javax.transaction.RollbackException: TransactionImple.enlistResource - ARJUNA016064: The transaction is in an invalid state!
at org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager.getConnection(XAShardingSphereTransactionManager.java:101)
at org.apache.shardingsphere.transaction.ConnectionTransaction.getConnection(ConnectionTransaction.java:102)
at org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.createConnection(DriverDatabaseConnectionManager
.java:416)
at org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.createConnections(DriverDatabaseConnectionManage
r.java:383)
at org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.getConnections(DriverDatabaseConnectionManager.j
ava:357)
at org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.getConnections(DriverDatabaseConnectionManager.j
ava:338)
at org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine.group(DriverExecutionPrepareEngine.java:89)
at org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine.prepare(AbstractExecutionPrepareEngine.java:73)
at org.apache.shardingsphere.infra.executor.sql.prepare.AbstractExecutionPrepareEngine.prepare(AbstractExecutionPrepareEngine.java:61)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.createExecutionGroupContext(ShardingSpherePrepare
dStatement.java:764)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.useDriverToExecute(ShardingSpherePreparedStatement.java:717)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.executeWithExecutionContexts(ShardingSpherePreparedStatement.java:658)
at org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement.execute(ShardingSpherePreparedStatement.java:631)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:44)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
问题分析
观察日志里有调用 setRollbackOnly 方法的日志,通过查看 setRollback
浙公网安备 33010602011771号