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

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


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new b591837e13b [fix](insert) Pick Insert init plan error may forget to 
abort txn (#34220) (#38260)
b591837e13b is described below

commit b591837e13b26bd99ef3886539e90f5eb3119244
Author: meiyi <[email protected]>
AuthorDate: Tue Jul 23 20:21:38 2024 +0800

    [fix](insert) Pick Insert init plan error may forget to abort txn (#34220) 
(#38260)
    
    Pick https://github.com/apache/doris/pull/34220
---
 .../trees/plans/commands/insert/InsertIntoTableCommand.java    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java
index 0d9f477f96b..f524ee9672a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java
@@ -137,7 +137,7 @@ public class InsertIntoTableCommand extends Command 
implements ForwardWithSync,
                     targetTableIf.getDatabase().getFullName() + "." + 
targetTableIf.getName());
         }
 
-        AbstractInsertExecutor insertExecutor;
+        AbstractInsertExecutor insertExecutor = null;
         // should lock target table until we begin transaction.
         targetTableIf.readLock();
         try {
@@ -199,8 +199,14 @@ public class InsertIntoTableCommand extends Command 
implements ForwardWithSync,
 
             insertExecutor.beginTransaction();
             insertExecutor.finalizeSink(planner.getFragments().get(0), sink, 
physicalSink);
-        } finally {
             targetTableIf.readUnlock();
+        } catch (Throwable e) {
+            targetTableIf.readUnlock();
+            // the abortTxn in onFail need to acquire table write lock
+            if (insertExecutor != null) {
+                insertExecutor.onFail(e);
+            }
+            throw e;
         }
 
         executor.setProfileType(ProfileType.LOAD);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to