This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 36876986208 Fix transaction auto commit (#30940)
36876986208 is described below
commit 368769862088988a45e2540701644833ebcac296
Author: ZhangCheng <[email protected]>
AuthorDate: Wed Apr 17 19:29:19 2024 +0800
Fix transaction auto commit (#30940)
* Fix transaction auto commit
* Fix transaction auto commit
---
.github/workflows/resources/filter/filters.yml | 6 +++---
.../driver/jdbc/core/connection/ShardingSphereConnection.java | 7 ++++++-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/.github/workflows/resources/filter/filters.yml
b/.github/workflows/resources/filter/filters.yml
index 0850fbc9c29..bd1e45014be 100644
--- a/.github/workflows/resources/filter/filters.yml
+++ b/.github/workflows/resources/filter/filters.yml
@@ -26,7 +26,7 @@ pipeline:
- 'features/readwrite-splitting/**/src/main/**'
- 'features/sharding/**/src/main/**'
- 'proxy/**/src/main/**'
- - 'jdbc/core/src/main/**'
+ - 'jdbc/src/main/**'
- '**/*-distsql*/**/src/main/**'
- 'kernel/data-pipeline/**/src/main/**'
- 'kernel/data-pipeline/**/pom.xml'
@@ -42,7 +42,7 @@ showprocesslist:
- 'infra/common/src/main/**'
- 'mode/**/src/main/**'
- 'proxy/**/src/main/**'
- - 'jdbc/core/src/main/**'
+ - 'jdbc/src/main/**'
- 'test/pom.xml'
- 'test/e2e/fixture/**'
- 'test/e2e/env/**'
@@ -53,7 +53,7 @@ transaction:
- 'infra/common/src/main/**'
- 'mode/**/src/main/**'
- 'proxy/**/src/main/**'
- - 'jdbc/core/src/main/**'
+ - 'jdbc/src/main/**'
- 'kernel/transaction/**/src/main/**'
- 'kernel/transaction/**/pom.xml'
- 'test/pom.xml'
diff --git
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index 07ca9d48590..e356a7b5b6d 100644
---
a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++
b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -203,7 +203,9 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
if
(TransactionType.isDistributedTransaction(databaseConnectionManager.getConnectionTransaction().getTransactionType()))
{
beginDistributedTransaction();
} else {
-
getConnectionContext().getTransactionContext().beginTransaction(String.valueOf(databaseConnectionManager.getConnectionTransaction().getTransactionType()));
+ if
(!getConnectionContext().getTransactionContext().isInTransaction()) {
+
getConnectionContext().getTransactionContext().beginTransaction(String.valueOf(databaseConnectionManager.getConnectionTransaction().getTransactionType()));
+ }
}
}
}
@@ -309,6 +311,9 @@ public final class ShardingSphereConnection extends
AbstractConnectionAdapter {
@Override
public void close() throws SQLException {
+ if
(databaseConnectionManager.getConnectionTransaction().isInTransaction()) {
+ databaseConnectionManager.getConnectionTransaction().rollback();
+ }
closed = true;
databaseConnectionManager.close();
processEngine.disconnect(processId);