This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 33d4d936a1c [fix](commit) Fix does not skip commit if txn state is 
committed or visible (#39786)
33d4d936a1c is described below

commit 33d4d936a1c46b0373144653077646ba6115bd18
Author: meiyi <myime...@gmail.com>
AuthorDate: Tue Aug 27 20:19:54 2024 +0800

    [fix](commit) Fix does not skip commit if txn state is committed or visible 
(#39786)
    
    introduced in #32980
    if a txn is committed twice, the check txn state is committed or visible
    and skip commit logic does not work
---
 .../doris/transaction/DatabaseTransactionMgr.java      | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
 
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
index 65f434ad588..3680f081d03 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/transaction/DatabaseTransactionMgr.java
@@ -690,7 +690,10 @@ public class DatabaseTransactionMgr {
         return writeDetail;
     }
 
-    private void checkTransactionStateBeforeCommit(Database db, List<Table> 
tableList, long transactionId,
+    /**
+     * @return true if the transaction need to commit, otherwise false
+     */
+    private boolean checkTransactionStateBeforeCommit(Database db, List<Table> 
tableList, long transactionId,
             boolean is2PC, TransactionState transactionState)
             throws TransactionCommitFailedException {
         if (transactionState == null) {
@@ -716,7 +719,7 @@ public class DatabaseTransactionMgr {
                 throw new TransactionCommitFailedException("transaction [" + 
transactionId
                         + "] is already visible, not pre-committed.");
             }
-            return;
+            return false;
         }
         if (transactionState.getTransactionStatus() == 
TransactionStatus.COMMITTED) {
             if (LOG.isDebugEnabled()) {
@@ -726,7 +729,7 @@ public class DatabaseTransactionMgr {
                 throw new TransactionCommitFailedException("transaction [" + 
transactionId
                         + "] is already committed, not pre-committed.");
             }
-            return;
+            return false;
         }
 
         if (is2PC && transactionState.getTransactionStatus() == 
TransactionStatus.PREPARE) {
@@ -765,6 +768,7 @@ public class DatabaseTransactionMgr {
                 }
             }
         }
+        return true;
     }
 
     /**
@@ -790,7 +794,9 @@ public class DatabaseTransactionMgr {
             readUnlock();
         }
 
-        checkTransactionStateBeforeCommit(db, tableList, transactionId, is2PC, 
transactionState);
+        if (!checkTransactionStateBeforeCommit(db, tableList, transactionId, 
is2PC, transactionState)) {
+            return;
+        }
 
         Set<Long> errorReplicaIds = Sets.newHashSet();
         Set<Long> totalInvolvedBackends = Sets.newHashSet();
@@ -846,7 +852,9 @@ public class DatabaseTransactionMgr {
                     "DebugPoint: 
DatabaseTransactionMgr.commitTransaction.failed");
         }
 
-        checkTransactionStateBeforeCommit(db, tableList, transactionId, false, 
transactionState);
+        if (!checkTransactionStateBeforeCommit(db, tableList, transactionId, 
false, transactionState)) {
+            return;
+        }
 
         // error replica may be duplicated for different sub transaction, but 
it's ok
         Set<Long> errorReplicaIds = Sets.newHashSet();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to