FlyingZC opened a new issue, #24231:
URL: https://github.com/apache/shardingsphere/issues/24231
## Bug Report
Obtaining a new connection in the xa transaction, executing sql and closing
the connection will cause the connection to close abnormally.
### Which version of ShardingSphere did you use?
Master.
### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
ShardingSphere-JDBC
### Expected behavior
Obtain a new connection within the xa transaction, execute sql and close the
connection without affecting the original xa transaction.
### Actual behavior
The connection is closed abnormally.
### Reason analyze (If you can)
Since the current xa connection is bound to the thread, opening a new
connection in the xa transaction will reuse the xa physical connection of the
current thread. When the connection is closed, the connection closed exception
will be reported in the xa transaction.
### Steps to reproduce the behavior, such as: SQL to execute, sharding rule
configuration, when exception occur etc.
```java
try (Connection connection = getDataSource().getConnection()) {
PreparedStatement statement = connection.prepareStatement("insert into
account(id, balance, transaction_id) values(?, ?, ?)");
connection.setAutoCommit(false);
statement.setLong(1, 1);
statement.setFloat(2, 1);
statement.setInt(3, 1);
statement.execute();
try (Connection connection2 = getDataSource().getConnection()) {
connection2.createStatement().executeQuery("select * from account");
}
connection.commit();
assertAccountRowCount(connection, 1);
}
```
### 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]