Skip to content

Commit

Permalink
Fix transaction auto commit (#30940)
Browse files Browse the repository at this point in the history
* Fix transaction auto commit

* Fix transaction auto commit
  • Loading branch information
FlyingZC authored Apr 17, 2024
1 parent 7ba3b4b commit 3687698
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/resources/filter/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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/**'
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ public void handleAutoCommit() throws SQLException {
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()));
}
}
}
}
Expand Down Expand Up @@ -309,6 +311,9 @@ public boolean isClosed() {

@Override
public void close() throws SQLException {
if (databaseConnectionManager.getConnectionTransaction().isInTransaction()) {
databaseConnectionManager.getConnectionTransaction().rollback();
}
closed = true;
databaseConnectionManager.close();
processEngine.disconnect(processId);
Expand Down

0 comments on commit 3687698

Please sign in to comment.