This is an automated email from the ASF dual-hosted git repository.
wuweijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 655c75431b0 fix: missing clear up savepoints when commits or
rollbacks. (#26819)
655c75431b0 is described below
commit 655c75431b0a5f906216f03b7fe0324e40d8dd0b
Author: kfirst <[email protected]>
AuthorDate: Sat Jul 8 09:48:55 2023 +0800
fix: missing clear up savepoints when commits or rollbacks. (#26819)
Co-authored-by: xiangxin.kong <[email protected]>
---
.../DriverDatabaseConnectionManager.java | 32 +++++++++++++++-------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
index 5391bbe040e..84395edff14 100644
---
a/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
+++
b/jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/DriverDatabaseConnectionManager.java
@@ -151,12 +151,18 @@ public final class DriverDatabaseConnectionManager
implements DatabaseConnection
* @throws SQLException SQL exception
*/
public void commit() throws SQLException {
- if (connectionTransaction.isLocalTransaction() &&
connectionTransaction.isRollbackOnly()) {
- forceExecuteTemplate.execute(cachedConnections.values(),
Connection::rollback);
- } else if (connectionTransaction.isLocalTransaction()) {
- forceExecuteTemplate.execute(cachedConnections.values(),
Connection::commit);
- } else {
- connectionTransaction.commit();
+ try {
+ if (connectionTransaction.isLocalTransaction() &&
connectionTransaction.isRollbackOnly()) {
+ forceExecuteTemplate.execute(cachedConnections.values(),
Connection::rollback);
+ } else if (connectionTransaction.isLocalTransaction()) {
+ forceExecuteTemplate.execute(cachedConnections.values(),
Connection::commit);
+ } else {
+ connectionTransaction.commit();
+ }
+ } finally {
+ for (Connection each : cachedConnections.values()) {
+
ConnectionSavepointManager.getInstance().transactionFinished(each);
+ }
}
}
@@ -166,10 +172,16 @@ public final class DriverDatabaseConnectionManager
implements DatabaseConnection
* @throws SQLException SQL exception
*/
public void rollback() throws SQLException {
- if (connectionTransaction.isLocalTransaction()) {
- forceExecuteTemplate.execute(cachedConnections.values(),
Connection::rollback);
- } else {
- connectionTransaction.rollback();
+ try {
+ if (connectionTransaction.isLocalTransaction()) {
+ forceExecuteTemplate.execute(cachedConnections.values(),
Connection::rollback);
+ } else {
+ connectionTransaction.rollback();
+ }
+ } finally {
+ for (Connection each : cachedConnections.values()) {
+
ConnectionSavepointManager.getInstance().transactionFinished(each);
+ }
}
}