FlyingZC opened a new issue, #28670:
URL: https://github.com/apache/shardingsphere/issues/28670
## Bug Report
When using xa transactions, after setAutoCommit(false)...commit...commit,
will report `java.lang.IllegalStateException: BaseTransaction.commit -
ARJUNA016074: no transaction!`.
### Which version of ShardingSphere did you use?
Master.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
JDBC
### Expected behavior
```java
protected void assertAutoCommitWithStatement() throws SQLException {
try (Connection connection = getDataSource().getConnection()) {
connection.setAutoCommit(false);
executeWithLog(connection, "DELETE FROM account");
assertFalse(connection.getAutoCommit());
executeWithLog(connection, "INSERT INTO account VALUES (1, 1, 1)");
connection.commit();
assertFalse(connection.getAutoCommit());
executeUpdateWithLog(connection, "INSERT INTO account VALUES (2,
2, 2)");
connection.commit();
assertFalse(connection.getAutoCommit());
executeWithLog(connection, "INSERT INTO account VALUES (3, 3, 3)");
connection.rollback();
assertFalse(connection.getAutoCommit());
assertAccountRowCount(connection, 2);
connection.setAutoCommit(true);
assertTrue(connection.getAutoCommit());
executeWithLog(connection, "INSERT INTO account VALUES (4, 4, 4)");
assertAccountRowCount(connection, 3);
}
}
```
### Actual behavior
```java
try (Connection connection = getDataSource().getConnection()) {
connection.setAutoCommit(false);
executeWithLog(connection, "DELETE FROM account");
assertFalse(connection.getAutoCommit());
executeWithLog(connection, "INSERT INTO account VALUES (1, 1, 1)");
connection.commit();
assertFalse(connection.getAutoCommit());
executeUpdateWithLog(connection, "INSERT INTO account VALUES (2,
2, 2)");
// Report java.lang.IllegalStateException: BaseTransaction.commit
- ARJUNA016074: no transaction!
connection.commit();
```
```
java.lang.IllegalStateException: BaseTransaction.commit - ARJUNA016074: no
transaction!
at
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
at
org.apache.shardingsphere.transaction.xa.XAShardingSphereTransactionManager.commit(XAShardingSphereTransactionManager.java:120)
at
org.apache.shardingsphere.transaction.ConnectionTransaction.commit(ConnectionTransaction.java:118)
at
org.apache.shardingsphere.driver.jdbc.core.connection.DriverDatabaseConnectionManager.commit(DriverDatabaseConnectionManager.java:159)
at
org.apache.shardingsphere.driver.jdbc.core.connection.ShardingSphereConnection.commit(ShardingSphereConnection.java:189)
```
### Reason analyze (If you can)
When using xa transactions, after setAutoCommit(false)...commit, autoCommit
is still false at this time, and we need to start xa transactions, otherwise an
error will be reported when committing again.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
### Example codes for reproduce this issue (such as a github link).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail:
[email protected]
For queries about this service, please contact Infrastructure at:
[email protected]