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

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


The following commit(s) were added to refs/heads/fe_local_shuffle by this push:
     new 73f5abd220e [fix](local shuffle) Old Coordinator must disable FE local 
shuffle planner for BE
73f5abd220e is described below

commit 73f5abd220e1d0b58f6aaa4a7121467ef0fe47a1
Author: 924060929 <[email protected]>
AuthorDate: Sun May 3 18:09:36 2026 +0800

    [fix](local shuffle) Old Coordinator must disable FE local shuffle planner 
for BE
    
    When canUseNereidsDistributePlanner=false (e.g. proxyExecute forwarding),
    FE uses old Coordinator which does not plan local exchange. But
    enable_local_shuffle_planner=true (default) tells BE not to plan its own
    LE either, causing pooling fragments to hang on SHUFFLE_DATA_DEPENDENCY.
    
    Fix:
    - Coordinator.initQueryOptions: always set enableLocalShufflePlanner=false
      since old Coordinator never plans LE
    - NereidsCoordinator.syncLocalShufflePlannerOption: set based on whether
      distributedPlans is available and session variable value
---
 .../main/java/org/apache/doris/qe/Coordinator.java |   4 +-
 .../org/apache/doris/qe/NereidsCoordinator.java    |  11 +++
 .../test_old_coordinator_local_shuffle.groovy      | 102 +++++++++++++++++++++
 3 files changed, 114 insertions(+), 3 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
index c35dfe1aa08..f165426f636 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
@@ -351,7 +351,6 @@ public class Coordinator implements CoordInterface {
         } else {
             distributedPlans = ((NereidsPlanner) 
planner).getDistributedPlans();
         }
-
         setFromUserProperty(context);
 
         
this.queryGlobals.setNowString(TimeUtils.getDatetimeFormatWithTimeZone().format(LocalDateTime.now()));
@@ -391,7 +390,6 @@ public class Coordinator implements CoordInterface {
         this.queryGlobals.setTimeZone(timezone);
         this.queryGlobals.setLoadZeroTolerance(loadZeroTolerance);
         this.queryOptions.setBeExecVersion(Config.be_exec_version);
-        this.queryOptions.setEnableLocalShufflePlanner(false);
 
         List<Integer> fragmentIds = new ArrayList<>();
         for (PlanFragment fragment : fragments) {
@@ -428,7 +426,7 @@ public class Coordinator implements CoordInterface {
         
this.queryOptions.setFeProcessUuid(ExecuteEnv.getInstance().getProcessUUID());
         this.queryOptions.setMysqlRowBinaryFormat(
                     context.getCommand() == MysqlCommand.COM_STMT_EXECUTE);
-        // Old Coordinator does not plan local exchange in FE. Force BE to 
plan its own.
+        // Old Coordinator never plans local exchange in FE. Force BE to plan 
its own.
         this.queryOptions.setEnableLocalShufflePlanner(false);
     }
 
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/qe/NereidsCoordinator.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/NereidsCoordinator.java
index 4084e4a84e8..de3ebc8f8bc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/NereidsCoordinator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/NereidsCoordinator.java
@@ -101,6 +101,7 @@ public class NereidsCoordinator extends Coordinator {
             setForInsert(-1L);
         }
 
+        syncLocalShufflePlannerOption();
         Preconditions.checkState(!planner.getFragments().isEmpty()
                 && coordinatorContext.instanceNum.get() > 0, "Fragment and 
Instance can not be empty˚");
     }
@@ -115,6 +116,7 @@ public class NereidsCoordinator extends Coordinator {
 
         // we don't need to check the dataSink, Because setting jobId means 
this must be a load operation
         setForInsert(jobId);
+        syncLocalShufflePlannerOption();
         Preconditions.checkState(!planner.getFragments().isEmpty()
                 && coordinatorContext.instanceNum.get() > 0, "Fragment and 
Instance can not be empty˚");
     }
@@ -132,11 +134,20 @@ public class NereidsCoordinator extends Coordinator {
         // same reason in `setForInsert`
         this.coordinatorContext.queryOptions.setDisableFileCache(true);
         this.needEnqueue = false;
+        syncLocalShufflePlannerOption();
 
         Preconditions.checkState(!fragments.isEmpty()
                 && coordinatorContext.instanceNum.get() > 0, "Fragment and 
Instance can not be empty˚");
     }
 
+    private void syncLocalShufflePlannerOption() {
+        coordinatorContext.queryOptions.setEnableLocalShufflePlanner(
+                coordinatorContext.distributedPlans != null
+                && !coordinatorContext.distributedPlans.isEmpty()
+                && coordinatorContext.connectContext != null
+                && 
coordinatorContext.connectContext.getSessionVariable().isEnableLocalShufflePlanner());
+    }
+
     @Override
     public void exec() throws Exception {
         enqueue(coordinatorContext.connectContext);
diff --git 
a/regression-test/suites/nereids_p0/local_shuffle/test_old_coordinator_local_shuffle.groovy
 
b/regression-test/suites/nereids_p0/local_shuffle/test_old_coordinator_local_shuffle.groovy
new file mode 100644
index 00000000000..649e488f851
--- /dev/null
+++ 
b/regression-test/suites/nereids_p0/local_shuffle/test_old_coordinator_local_shuffle.groovy
@@ -0,0 +1,102 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+/**
+ * Regression test: old Coordinator + enable_local_shuffle_planner must not 
hang.
+ *
+ * When canUseNereidsDistributePlanner=false (e.g. proxyExecute forwarding),
+ * FE uses old Coordinator which does not plan local exchange. If
+ * enable_local_shuffle_planner=true was passed to BE, BE would skip its own
+ * _plan_local_exchange, leaving no LE at all — causing pooling fragments to
+ * hang on SHUFFLE_DATA_DEPENDENCY.
+ *
+ * Fix: old Coordinator forces enableLocalShufflePlanner=false in query options
+ * when distributedPlans is null, so BE falls back to native LE planning.
+ */
+suite("test_old_coordinator_local_shuffle") {
+
+    sql "DROP TABLE IF EXISTS oc_t0"
+    sql "DROP TABLE IF EXISTS oc_t1"
+
+    sql """
+        CREATE TABLE oc_t0 (
+            pk INT NULL,
+            k1 INT NULL,
+            v1 INT NULL
+        ) ENGINE=OLAP
+        UNIQUE KEY(pk, k1)
+        DISTRIBUTED BY HASH(pk) BUCKETS 10
+        PROPERTIES (
+            'replication_allocation' = 'tag.location.default: 1',
+            'enable_unique_key_merge_on_write' = 'true'
+        )
+    """
+
+    sql """
+        CREATE TABLE oc_t1 (
+            pk INT NULL,
+            k1 INT NULL,
+            v1 INT NULL
+        ) ENGINE=OLAP
+        UNIQUE KEY(pk, k1)
+        DISTRIBUTED BY HASH(pk) BUCKETS 10
+        PROPERTIES (
+            'replication_allocation' = 'tag.location.default: 1',
+            'enable_unique_key_merge_on_write' = 'true'
+        )
+    """
+
+    sql "INSERT INTO oc_t0 VALUES (1,1,10),(2,2,20),(3,3,30),(4,4,40),(5,5,50)"
+    sql "INSERT INTO oc_t1 VALUES 
(1,1,100),(2,2,200),(3,3,300),(6,6,600),(7,7,700)"
+
+    // Test 1: old Coordinator + default enable_local_shuffle_planner=true
+    // This simulates the proxyExecute forwarding scenario where
+    // canUseNereidsDistributePlanner=false.
+    sql "SET enable_nereids_distribute_planner = false"
+    sql "SET enable_local_shuffle = true"
+    sql "SET ignore_storage_data_distribution = true"
+    sql "SET query_timeout = 30"
+
+    sql """
+        MERGE INTO oc_t0 t USING oc_t1 s
+        ON t.pk = s.pk AND t.k1 = s.k1
+        WHEN MATCHED THEN UPDATE SET v1 = s.v1
+        WHEN NOT MATCHED THEN INSERT (pk, k1, v1) VALUES (s.pk, s.k1, s.v1)
+    """
+
+    def result = sql "SELECT * FROM oc_t0 ORDER BY pk"
+    assertEquals(7, result.size())
+
+    // Test 2: INSERT INTO SELECT with FE-planned LE should not double-insert 
LE.
+    // NereidsCoordinator has distributedPlans != null, so 
enableLocalShufflePlanner
+    // stays true and BE does not add its own LE on top of FE's.
+    sql "SET enable_nereids_distribute_planner = true"
+    sql "SET enable_local_shuffle_planner = true"
+
+    sql "TRUNCATE TABLE oc_t0"
+    sql """
+        INSERT INTO oc_t0
+        SELECT number, number % 10, number * 100
+        FROM numbers('number' = '50')
+    """
+
+    def cnt = sql "SELECT COUNT(*) FROM oc_t0"
+    assertEquals(50, cnt[0][0] as int)
+
+    sql "DROP TABLE IF EXISTS oc_t0"
+    sql "DROP TABLE IF EXISTS oc_t1"
+}


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

Reply via email to