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 3eeb6391f82 Fix transaction deadlock test case (#30099)
3eeb6391f82 is described below
commit 3eeb6391f8263883fde6e35be39d3c90379bac9b
Author: ZhangCheng <[email protected]>
AuthorDate: Tue Feb 13 08:16:25 2024 +0800
Fix transaction deadlock test case (#30099)
---
.../transaction/cases/deadlock/TransactionDeadlockTestCase.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/deadlock/TransactionDeadlockTestCase.java
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/deadlock/TransactionDeadlockTestCase.java
index 8a8f1d7e9b1..113ab464fcb 100644
---
a/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/deadlock/TransactionDeadlockTestCase.java
+++
b/test/e2e/operation/transaction/src/test/java/org/apache/shardingsphere/test/e2e/transaction/cases/deadlock/TransactionDeadlockTestCase.java
@@ -73,9 +73,6 @@ public final class TransactionDeadlockTestCase extends
BaseTransactionTestCase {
Collection<Future<Void>> futures = new LinkedList<>();
futures.add(executor.submit(this::executeTransfer1));
futures.add(executor.submit(this::executeTransfer2));
- try (Connection connection = getDataSource().getConnection()) {
- assertAccountRowCount(connection, 4);
- }
for (Future<Void> each : futures) {
try {
each.get();
@@ -88,7 +85,7 @@ public final class TransactionDeadlockTestCase extends
BaseTransactionTestCase {
log.info("The deadlock test case execution time is: {}",
System.currentTimeMillis() - startTime);
executor.shutdown();
try (Connection connection = getDataSource().getConnection()) {
- assertAccountBalances(connection, 1, 2, 3, 4);
+ assertAccountRowCount(connection, 4);
}
}
@@ -96,12 +93,14 @@ public final class TransactionDeadlockTestCase extends
BaseTransactionTestCase {
Connection connection = getDataSource().getConnection();
try {
connection.setAutoCommit(false);
+ assertAccountRowCount(connection, 4);
executeWithLog(connection, "UPDATE account SET balance = balance -
1 WHERE id = 1");
await();
executeWithLog(connection, "UPDATE account SET balance = balance +
1 WHERE id = 2");
await();
connection.commit();
} catch (final SQLException ex) {
+ await();
connection.rollback();
throw ex;
} finally {
@@ -114,12 +113,14 @@ public final class TransactionDeadlockTestCase extends
BaseTransactionTestCase {
Connection connection = getDataSource().getConnection();
try {
connection.setAutoCommit(false);
+ assertAccountRowCount(connection, 4);
executeWithLog(connection, "UPDATE account SET balance = balance -
1 WHERE id = 2");
await();
executeWithLog(connection, "UPDATE account SET balance = balance +
1 WHERE id = 1");
await();
connection.commit();
} catch (final SQLException ex) {
+ await();
connection.rollback();
throw ex;
} finally {