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

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


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 51af9befd3e branch-4.0: [fix](insert) do not generate next id when fe 
is not master #56959 (#56966)
51af9befd3e is described below

commit 51af9befd3e694795ff447147c781e02be5fac72
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Oct 16 09:59:32 2025 +0800

    branch-4.0: [fix](insert) do not generate next id when fe is not master 
#56959 (#56966)
    
    Cherry-picked from #56959
    
    Co-authored-by: hui lai <[email protected]>
---
 .../trees/plans/commands/insert/AbstractInsertExecutor.java        | 7 +++++--
 .../trees/plans/commands/insert/InsertIntoTableCommand.java        | 6 +++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/AbstractInsertExecutor.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/AbstractInsertExecutor.java
index 4448456b934..add51ba7320 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/AbstractInsertExecutor.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/AbstractInsertExecutor.java
@@ -18,6 +18,7 @@
 package org.apache.doris.nereids.trees.plans.commands.insert;
 
 import org.apache.doris.catalog.DatabaseIf;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.EnvFactory;
 import org.apache.doris.catalog.TableIf;
 import org.apache.doris.common.Config;
@@ -77,8 +78,10 @@ public abstract class AbstractInsertExecutor {
             Optional<InsertCommandContext> insertCtx, boolean emptyInsert) {
         this.ctx = ctx;
         this.database = table.getDatabase();
-        this.insertLoadJob = new InsertLoadJob(database.getId(), labelName);
-        ctx.getEnv().getLoadManager().addLoadJob(insertLoadJob);
+        if (Env.getCurrentEnv().isMaster()) {
+            this.insertLoadJob = new InsertLoadJob(database.getId(), 
labelName);
+            ctx.getEnv().getLoadManager().addLoadJob(insertLoadJob);
+        }
         this.coordinator = EnvFactory.getInstance().createCoordinator(
                 ctx, planner, ctx.getStatsErrorEstimator(), 
insertLoadJob.getId());
         this.labelName = labelName;
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 c507fb4d122..b1fbecfe2d1 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
@@ -133,7 +133,11 @@ public class InsertIntoTableCommand extends Command 
implements NeedAuditEncrypti
         this.cte = cte;
         this.needNormalizePlan = needNormalizePlan;
         this.branchName = branchName;
-        this.jobId = Env.getCurrentEnv().getNextId();
+        if (Env.getCurrentEnv().isMaster()) {
+            this.jobId = Env.getCurrentEnv().getNextId();
+        } else {
+            this.jobId = -1;
+        }
     }
 
     /**


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

Reply via email to