You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "FlyingZC (via GitHub)" <gi...@apache.org> on 2023/10/08 01:04:21 UTC

[I] Auto commit bug in jdbc adapter [shardingsphere]

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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] Auto commit bug in jdbc adapter [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed issue #28670: Auto commit bug in jdbc adapter
URL: https://github.com/apache/shardingsphere/issues/28670


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org