This is an automated email from the ASF dual-hosted git repository.
huajianlan 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 a2bfd923e97 [refactor](local shuffle) Refactor FE local exchange
planning: extract helper, fix root PASSTHROUGH, fix ScanNode output
a2bfd923e97 is described below
commit a2bfd923e97fd2af21a0c236d836dd173d0d4729
Author: 924060929 <[email protected]>
AuthorDate: Fri Apr 10 13:06:21 2026 +0800
[refactor](local shuffle) Refactor FE local exchange planning: extract
helper, fix root PASSTHROUGH, fix ScanNode output
1. Extract duplicated heavy-ops bottleneck avoidance code from enforceChild/
enforceChildExchange/forceEnforceChildExchange into
insertLocalExchange().
2. Fix root-level PASSTHROUGH insertion: only check
newRoot.isSerialOperator()
instead of recursive hasSerialChildren() — after
enforceAndDeriveLocalExchange(),
serial children are already handled by LocalExchangeNodes inserted
during tree walk.
This fixes 6 FE/BE consistency mismatches where FE inserted ~2x
PASSTHROUGH vs BE.
3. Fix ScanNode base class: return NOOP instead of BUCKET_HASH_SHUFFLE (only
OlapScanNode should report bucket distribution for non-pooling scans).
4. Remove ExchangeNode.toThrift() dependency on hasSerialScanNode() — with
FE-planned
local exchanges, serial scans are handled by PASSTHROUGH fan-out.
5. Fix DistributePlanner: BUCKET_SHUFFLE with local shuffle returns all
instances
(not just first-per-worker); use assignedJoinBucketIndexes for bucket
mapping.
6. Cap parallelism in UnassignedScanBucketOlapTableJob when fragment has
non-serial
exchange to avoid padding instances that hang.
7. Remove dead DataStreamSink.getLocalExchangeTypeRequire() override.
8. Inline shouldUseLocalExecutionHash() constant.
9. Fix test Bug 18/19: use col_int_undef_signed (existing column) instead of
col_varchar_10__undef_signed (non-existent).
---
.../trees/plans/distribute/DistributePlanner.java | 24 ++++-
.../job/UnassignedScanBucketOlapTableJob.java | 23 ++++-
.../org/apache/doris/planner/AddLocalExchange.java | 36 +++----
.../org/apache/doris/planner/DataStreamSink.java | 5 -
.../org/apache/doris/planner/ExchangeNode.java | 15 ++-
.../org/apache/doris/planner/OlapScanNode.java | 8 +-
.../java/org/apache/doris/planner/PlanNode.java | 111 ++++++++-------------
.../java/org/apache/doris/planner/ScanNode.java | 8 +-
.../test_local_shuffle_rqg_bugs.groovy | 8 +-
9 files changed, 123 insertions(+), 115 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/DistributePlanner.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/DistributePlanner.java
index 0069ddd37db..48a7ba39413 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/DistributePlanner.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/DistributePlanner.java
@@ -31,6 +31,7 @@ import
org.apache.doris.nereids.trees.plans.distribute.worker.job.AssignedJobBui
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.BucketScanSource;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.DefaultScanSource;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.LocalShuffleAssignedJob;
+import
org.apache.doris.nereids.trees.plans.distribute.worker.job.LocalShuffleBucketJoinAssignedJob;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.StaticAssignedJob;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.UnassignedJob;
import
org.apache.doris.nereids.trees.plans.distribute.worker.job.UnassignedJobBuilder;
@@ -244,6 +245,13 @@ public class DistributePlanner {
boolean useLocalShuffle = receiverPlan.getInstanceJobs().stream()
.anyMatch(LocalShuffleAssignedJob.class::isInstance);
if (useLocalShuffle) {
+ // For BUCKET_SHUFFLE with local shuffle, each instance handles
specific buckets.
+ // The exchange must route data to each instance individually, not
just the first
+ // per worker. Otherwise instances 1..N-1 create ExchangeSource
tasks that never
+ // receive data or EOS, causing a hang.
+ if (linkNode.getPartitionType() ==
TPartitionType.BUCKET_SHFFULE_HASH_PARTITIONED) {
+ return receiverPlan.getInstanceJobs();
+ }
return getFirstInstancePerWorker(receiverPlan.getInstanceJobs());
} else if (enableShareHashTableForBroadcastJoin &&
linkNode.isRightChildOfBroadcastHashJoin()) {
return getFirstInstancePerWorker(receiverPlan.getInstanceJobs());
@@ -256,8 +264,20 @@ public class DistributePlanner {
PipelineDistributedPlan plan, List<AssignedJob> unsorted, int
bucketNum) {
AssignedJob[] instances = new AssignedJob[bucketNum];
for (AssignedJob instanceJob : unsorted) {
- BucketScanSource bucketScanSource = (BucketScanSource)
instanceJob.getScanSource();
- for (Integer bucketIndex :
bucketScanSource.bucketIndexToScanNodeToTablets.keySet()) {
+ // For LocalShuffleBucketJoinAssignedJob, use
assignedJoinBucketIndexes which
+ // gives the specific join bucket(s) this instance handles. The
scanSource
+ // buckets include ALL buckets on this worker (shared via pooling
scan),
+ // which would cause collisions when multiple instances on the
same worker
+ // each handle different join buckets.
+ Iterable<Integer> bucketIndices;
+ if (instanceJob instanceof LocalShuffleBucketJoinAssignedJob) {
+ bucketIndices = ((LocalShuffleBucketJoinAssignedJob)
instanceJob)
+ .getAssignedJoinBucketIndexes();
+ } else {
+ BucketScanSource bucketScanSource = (BucketScanSource)
instanceJob.getScanSource();
+ bucketIndices =
bucketScanSource.bucketIndexToScanNodeToTablets.keySet();
+ }
+ for (Integer bucketIndex : bucketIndices) {
if (instances[bucketIndex] != null) {
throw new IllegalStateException(
"Multi instances scan same buckets: " +
instances[bucketIndex] + " and " + instanceJob
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/job/UnassignedScanBucketOlapTableJob.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/job/UnassignedScanBucketOlapTableJob.java
index 6a2315966bc..0bb4033fdf9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/job/UnassignedScanBucketOlapTableJob.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/distribute/worker/job/UnassignedScanBucketOlapTableJob.java
@@ -539,6 +539,27 @@ public class UnassignedScanBucketOlapTableJob extends
AbstractUnassignedScanJob
}
int maxParallelism = (int) Math.max(tabletNum,
fragment.getParallelExecNum());
- return Math.min(maxParallelism, colocateMaxParallelNum);
+ int result = Math.min(maxParallelism, colocateMaxParallelNum);
+
+ // When the fragment has a non-serial exchange, the BE won't insert
local exchange
+ // for the exchange pipeline (distribution matches
BUCKET_HASH_SHUFFLE). Instances
+ // beyond per-BE bucket count are "padding" with no bucket assignment
— they create
+ // VDataStreamRecvrs that never receive data and hang. Cap at per-BE
bucket count.
+ if (useLocalShuffleToAddParallel && hasNonSerialExchangeInFragment()) {
+ result = Math.min(result, maxParallel);
+ }
+
+ return result;
+ }
+
+ private boolean hasNonSerialExchangeInFragment() {
+ List<ExchangeNode> exchanges = fragment.getPlanRoot()
+ .collectInCurrentFragment(ExchangeNode.class::isInstance);
+ for (ExchangeNode exchange : exchanges) {
+ if (!exchange.isSerialOperator()) {
+ return true;
+ }
+ }
+ return false;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/AddLocalExchange.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/AddLocalExchange.java
index 40b79a03471..2c76474b21e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/AddLocalExchange.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AddLocalExchange.java
@@ -70,17 +70,16 @@ public class AddLocalExchange {
Pair<PlanNode, LocalExchangeType> output = root
.enforceAndDeriveLocalExchange(context, null, require);
PlanNode newRoot = output.first;
- // Mirror BE OperatorBase base class required_data_distribution():
- // when any operator in the fragment plan is serial AND the fragment
uses pooling scan
- // (LocalShuffleAssignedJob → ignoreDataDistribution →
_parallel_instances=1),
- // serial operators reduce pipeline num_tasks to 1, and this
propagates via
- // add_pipeline() to all downstream pipelines (including the
DataStreamSink pipeline).
- // Only instance 0 creates tasks and sends EOS. Downstream receivers
expect
- // _num_instances EOSes → hang.
+ // The DataStreamSink runs in the same pipeline as the fragment root.
+ // If the root is serial in a pooling-scan fragment, the sink pipeline
has 1 task
+ // and only instance 0 sends EOS → downstream receivers hang.
// Insert PASSTHROUGH fan-out to create _num_instances sink tasks.
- // Non-pooling fragments (regular bucket distribution) have
_num_instances ==
- // bucket_count and every instance gets a scan range, so all sink
tasks run.
- if (isLocalShuffle && (newRoot.isSerialOperator() ||
newRoot.hasSerialChildren())) {
+ //
+ // Only check the root node itself (not recursive hasSerialChildren),
because
+ // after enforceAndDeriveLocalExchange(), any serial children deeper
in the tree
+ // are already handled by LocalExchangeNodes inserted during the tree
walk.
+ // Those LocalExchangeNodes create pipeline boundaries with
_num_instances tasks.
+ if (isLocalShuffle && newRoot.isSerialOperator()) {
newRoot = new LocalExchangeNode(context.nextPlanNodeId(), newRoot,
LocalExchangeType.PASSTHROUGH, null);
}
@@ -116,22 +115,17 @@ public class AddLocalExchange {
public static LocalExchangeType
resolveExchangeType(LocalExchangeTypeRequire require,
PlanTranslatorContext translatorContext, PlanNode parent, PlanNode
child) {
- // Only generic RequireHash adapts to LOCAL_EXECUTION_HASH_SHUFFLE
based on context.
+ // Only generic RequireHash adapts to LOCAL_EXECUTION_HASH_SHUFFLE.
// Explicit RequireSpecific (GLOBAL_EXECUTION_HASH_SHUFFLE,
BUCKET_HASH_SHUFFLE, etc.)
// must never be degraded — if they appear in an invalid context, the
plan is wrong.
- if (require instanceof RequireHash
- && shouldUseLocalExecutionHash(translatorContext, parent,
child)) {
- return LocalExchangeType.LOCAL_EXECUTION_HASH_SHUFFLE;
- }
- return require.preferType();
- }
-
- private static boolean shouldUseLocalExecutionHash(
- PlanTranslatorContext translatorContext, PlanNode parent, PlanNode
child) {
+ //
// Always prefer LOCAL_EXECUTION_HASH_SHUFFLE for FE-planned
intra-fragment hash exchanges.
// GLOBAL_EXECUTION_HASH_SHUFFLE requires shuffle_idx_to_instance_idx
which may be empty
// for fragments with non-hash sinks (UNPARTITIONED/MERGE). LOCAL_HASH
is always safe
// since it partitions by local instance count without needing
external shuffle maps.
- return true;
+ if (require instanceof RequireHash) {
+ return LocalExchangeType.LOCAL_EXECUTION_HASH_SHUFFLE;
+ }
+ return require.preferType();
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/DataStreamSink.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/DataStreamSink.java
index ddf246a3a5f..e6998ee72ae 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/DataStreamSink.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/DataStreamSink.java
@@ -25,7 +25,6 @@ import org.apache.doris.analysis.ExprToSqlVisitor;
import org.apache.doris.analysis.ExprToThriftVisitor;
import org.apache.doris.analysis.ToSqlParams;
import org.apache.doris.analysis.TupleDescriptor;
-import org.apache.doris.planner.LocalExchangeNode.LocalExchangeTypeRequire;
import org.apache.doris.thrift.TDataSink;
import org.apache.doris.thrift.TDataSinkType;
import org.apache.doris.thrift.TDataStreamSink;
@@ -241,8 +240,4 @@ public class DataStreamSink extends DataSink {
return result;
}
- @Override
- public LocalExchangeTypeRequire getLocalExchangeTypeRequire() {
- return LocalExchangeTypeRequire.noRequire();
- }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
index 4f03834ab9b..f822f0b6c96 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/ExchangeNode.java
@@ -102,15 +102,12 @@ public class ExchangeNode extends PlanNode {
@Override
protected void toThrift(TPlanNode msg) {
- // If this fragment has another scan node, this exchange node is
serial or not should be decided by the scan
- // node.
- // When FE-planned local shuffle is enabled, ExchangeNode's serial
flag is preserved
- // (same as BE-planned path). The ExchangeNode pipeline will have
num_tasks=1 when serial,
- // meaning only instance 0 creates a task. This is correct because FE's
- // filterInstancesWhichCanReceiveDataFromRemote() ensures only the
first instance per
- // worker receives remote data. The deferred exchanger uses
upstream_pipe->num_tasks()
- // to get the correct sender_count.
- msg.setIsSerialOperator((isSerialOperator() ||
fragment.hasSerialScanNode())
+ // Exchange serial status should depend only on isSerialOperator()
(UNPARTITIONED or
+ // use_serial_exchange), NOT on fragment.hasSerialScanNode(). With
FE-planned local
+ // exchanges, serial scans are already handled by PASSTHROUGH fan-out.
Making
+ // non-UNPARTITIONED exchanges (e.g. BUCKET_SHUFFLE) serial would
reduce the build-side
+ // pipeline to num_tasks=1, preventing shared state propagation to
other instances.
+ msg.setIsSerialOperator(isSerialOperator()
&& fragment.useSerialSource(ConnectContext.get()));
msg.node_type = TPlanNodeType.EXCHANGE_NODE;
msg.exchange_node = new TExchangeNode();
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
index 1e490035155..f8c43c2ca55 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java
@@ -1419,6 +1419,12 @@ public class OlapScanNode extends ScanNode {
public Pair<PlanNode, LocalExchangeType> enforceAndDeriveLocalExchange(
PlanTranslatorContext translatorContext, PlanNode parent,
LocalExchangeTypeRequire parentRequire) {
- return super.enforceAndDeriveLocalExchange(translatorContext, parent,
parentRequire);
+ boolean useSerialSource = fragment != null
+ &&
fragment.useSerialSource(translatorContext.getConnectContext());
+ if (useSerialSource) {
+ return Pair.of(this, LocalExchangeType.NOOP);
+ }
+ // Non-pooling OlapScan has bucket distribution — each instance scans
specific buckets
+ return Pair.of(this, LocalExchangeType.BUCKET_HASH_SHUFFLE);
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
index 805d419b86b..cad9745c9eb 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/PlanNode.java
@@ -966,15 +966,19 @@ public abstract class PlanNode extends TreeNode<PlanNode>
{
return Pair.of(this, LocalExchangeType.NOOP);
}
+ /**
+ * Enforce a local exchange requirement on a child, respecting
serial-ancestor semantics.
+ * If this node or an ancestor in the same pipeline is serial, the
exchange is skipped
+ * (mirrors BE's need_to_local_exchange: any_of(operators[idx..end],
is_serial) → skip).
+ * Returns (resultNode, outputType) where outputType is the resolved
exchange type
+ * (preferType when an exchange is inserted).
+ */
protected Pair<PlanNode, LocalExchangeType> enforceChild(
PlanTranslatorContext translatorContext, LocalExchangeTypeRequire
requireChild, PlanNode originChild) {
int childIndex = children.indexOf(originChild);
Pair<PlanNode, LocalExchangeType> childOutput =
deriveAndEnforceChildLocalExchange(
translatorContext, originChild, requireChild, childIndex);
if (!requireChild.satisfy(childOutput.second)) {
- // Mirror BE's need_to_local_exchange: if any operator at or after
the current position
- // is serial (including this node itself), skip the exchange.
- // BE: any_of(operators[idx..end], is_serial) → return false
if (translatorContext.hasSerialAncestorInPipeline(this) ||
isSerialOperator()) {
return childOutput;
}
@@ -984,27 +988,9 @@ public abstract class PlanNode extends TreeNode<PlanNode> {
return childOutput;
}
List<Expr> distributeExprs = childIndex >= 0 ?
getChildDistributeExprList(childIndex) : null;
- // Heavy ops bottleneck avoidance (mirrors BE
pipeline_fragment_context.cpp:1025-1038):
- // Heavy ops bottleneck avoidance (mirrors BE
pipeline_fragment_context.cpp:1025-1038):
- // When upstream has 1 task (serial source) and exchange is heavy,
insert PASSTHROUGH
- // fan-out first to avoid single-task bottleneck on the heavy
exchange sink.
- // Only applies to local-shuffle fragments (pooling scan) where
_parallel_instances=1
- // causes serial pipelines to have 1 task. In non-pooling
fragments, each instance
- // has its own scan range and all pipelines have _num_instances
tasks.
- if (translatorContext.isLocalShuffleFragment()
- && preferType.isHeavyOperation() &&
childOutput.first.isSerialOperator()) {
- PlanNode ptNode = new
LocalExchangeNode(translatorContext.nextPlanNodeId(),
- childOutput.first, LocalExchangeType.PASSTHROUGH,
null);
- return Pair.of(
- new
LocalExchangeNode(translatorContext.nextPlanNodeId(), ptNode,
- preferType, distributeExprs),
- preferType);
- }
- return Pair.of(
- new LocalExchangeNode(translatorContext.nextPlanNodeId(),
childOutput.first,
- preferType, distributeExprs),
- preferType
- );
+ PlanNode wrapped = insertLocalExchange(
+ translatorContext, childOutput.first, preferType,
distributeExprs);
+ return Pair.of(wrapped, preferType);
} else {
return childOutput;
}
@@ -1022,14 +1008,11 @@ public abstract class PlanNode extends
TreeNode<PlanNode> {
}
/**
- * Enforces a local exchange requirement on a single child without the
serial-ancestor
- * check or heavy-ops bottleneck avoidance that {@link #enforceChild}
applies.
+ * Enforce a local exchange requirement on a child without the
serial-ancestor check.
* Use for nodes whose children's distribution requirements must be
satisfied regardless
* of serial ancestors in the same pipeline (joins, set operations, etc.).
- *
- * @return (resultNode, childOutputType) — resultNode may be a new
LocalExchangeNode wrapper
- * if an exchange was inserted; childOutputType is the child's
reported output
- * distribution before any inserted exchange (useful for deriving
the parent's output).
+ * Returns (resultNode, childOutputType) where childOutputType is the
child's reported
+ * output distribution before any inserted exchange (useful for deriving
the parent's output).
*/
protected Pair<PlanNode, LocalExchangeType> enforceChildExchange(
PlanTranslatorContext translatorContext, LocalExchangeTypeRequire
require,
@@ -1040,33 +1023,19 @@ public abstract class PlanNode extends
TreeNode<PlanNode> {
LocalExchangeType preferType =
AddLocalExchange.resolveExchangeType(
require, translatorContext, this, childOutput.first);
List<Expr> distributeExprs =
getChildDistributeExprList(childIndex);
- // Heavy ops bottleneck avoidance (same as enforceChild):
- // serial child + heavy exchange → insert PASSTHROUGH fan-out first
- // Only for local-shuffle (pooling scan) fragments where serial
means 1 task.
- if (translatorContext.isLocalShuffleFragment()
- && preferType.isHeavyOperation() &&
childOutput.first.isSerialOperator()) {
- PlanNode ptNode = new
LocalExchangeNode(translatorContext.nextPlanNodeId(),
- childOutput.first, LocalExchangeType.PASSTHROUGH,
null);
- return Pair.of(
- new
LocalExchangeNode(translatorContext.nextPlanNodeId(), ptNode,
- preferType, distributeExprs),
- childOutput.second);
- }
- return Pair.of(
- new LocalExchangeNode(translatorContext.nextPlanNodeId(),
childOutput.first,
- preferType, distributeExprs),
- childOutput.second);
+ PlanNode wrapped = insertLocalExchange(
+ translatorContext, childOutput.first, preferType,
distributeExprs);
+ return Pair.of(wrapped, childOutput.second);
}
return childOutput;
}
/**
* Like {@link #enforceChildExchange} but always inserts a local exchange
- * when the require is not noRequire, even if the child already outputs a
- * matching distribution. This mirrors BE's need_to_local_exchange Step 4
- * which always inserts non-hash exchanges regardless of the current
- * distribution. Used by NLJ probe side where each NLJ creates a pipeline
- * boundary and data must be re-partitioned.
+ * when the require is not NOOP, even if the child already outputs a
matching distribution.
+ * Mirrors BE's need_to_local_exchange Step 4 which always inserts
non-hash exchanges
+ * regardless of the current distribution. Used by NLJ probe side where
each NLJ creates
+ * a pipeline boundary and data must be re-partitioned.
*/
protected Pair<PlanNode, LocalExchangeType> forceEnforceChildExchange(
PlanTranslatorContext translatorContext, LocalExchangeTypeRequire
require,
@@ -1077,26 +1046,34 @@ public abstract class PlanNode extends
TreeNode<PlanNode> {
LocalExchangeType preferType =
AddLocalExchange.resolveExchangeType(
require, translatorContext, this, childOutput.first);
List<Expr> distributeExprs =
getChildDistributeExprList(childIndex);
- // Heavy ops bottleneck avoidance (same as enforceChild):
- // serial child + heavy exchange → insert PASSTHROUGH fan-out first
- // Only for local-shuffle (pooling scan) fragments where serial
means 1 task.
- if (translatorContext.isLocalShuffleFragment()
- && preferType.isHeavyOperation() &&
childOutput.first.isSerialOperator()) {
- PlanNode ptNode = new
LocalExchangeNode(translatorContext.nextPlanNodeId(),
- childOutput.first, LocalExchangeType.PASSTHROUGH,
null);
- return Pair.of(
- new
LocalExchangeNode(translatorContext.nextPlanNodeId(), ptNode,
- preferType, distributeExprs),
- childOutput.second);
- }
- return Pair.of(
- new LocalExchangeNode(translatorContext.nextPlanNodeId(),
childOutput.first,
- preferType, distributeExprs),
- childOutput.second);
+ PlanNode wrapped = insertLocalExchange(
+ translatorContext, childOutput.first, preferType,
distributeExprs);
+ return Pair.of(wrapped, childOutput.second);
}
return childOutput;
}
+ /**
+ * Insert a LocalExchangeNode wrapping {@code child} with the given
exchange type.
+ * Handles heavy-ops bottleneck avoidance (mirrors BE
pipeline_fragment_context.cpp):
+ * when upstream has 1 task (serial source) and exchange is heavy
(hash/bucket/adaptive),
+ * insert a PASSTHROUGH fan-out first to avoid single-task bottleneck on
the heavy
+ * exchange sink. Only applies to local-shuffle (pooling scan) fragments
where
+ * _parallel_instances=1 causes serial pipelines to have 1 task.
+ */
+ private PlanNode insertLocalExchange(PlanTranslatorContext
translatorContext,
+ PlanNode child, LocalExchangeType exchangeType, List<Expr>
distributeExprs) {
+ if (translatorContext.isLocalShuffleFragment()
+ && exchangeType.isHeavyOperation() &&
child.isSerialOperator()) {
+ PlanNode ptNode = new
LocalExchangeNode(translatorContext.nextPlanNodeId(),
+ child, LocalExchangeType.PASSTHROUGH, null);
+ return new LocalExchangeNode(translatorContext.nextPlanNodeId(),
ptNode,
+ exchangeType, distributeExprs);
+ }
+ return new LocalExchangeNode(translatorContext.nextPlanNodeId(), child,
+ exchangeType, distributeExprs);
+ }
+
/**
* Whether the child at {@code childIndex} starts a new pipeline context,
causing
* its serial-ancestor flag to be reset to {@code false} rather than
inherited from this node.
diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
index eeae669c18d..ccb07665dff 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/planner/ScanNode.java
@@ -725,11 +725,9 @@ public abstract class ScanNode extends PlanNode implements
SplitGenerator {
@Override
public Pair<PlanNode, LocalExchangeType> enforceAndDeriveLocalExchange(
PlanTranslatorContext translatorContext, PlanNode parent,
LocalExchangeTypeRequire parentRequire) {
- boolean useSerialSource = fragment != null &&
fragment.useSerialSource(translatorContext.getConnectContext());
- if (useSerialSource) {
- return Pair.of(this, LocalExchangeType.NOOP);
- }
- return Pair.of(this, LocalExchangeType.BUCKET_HASH_SHUFFLE);
+ // Base ScanNode returns NOOP — only OlapScanNode overrides with
BUCKET_HASH_SHUFFLE
+ // for non-pooling scans that have bucket distribution.
+ return Pair.of(this, LocalExchangeType.NOOP);
}
public void setDesc(TupleDescriptor desc) {
diff --git
a/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_rqg_bugs.groovy
b/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_rqg_bugs.groovy
index 8009957ec5d..72b41074fe5 100644
---
a/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_rqg_bugs.groovy
+++
b/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_rqg_bugs.groovy
@@ -1004,7 +1004,7 @@ suite("test_local_shuffle_rqg_bugs") {
def bug18_baseline = sql """
SELECT /*+SET_VAR(enable_local_shuffle_planner=false,
enable_sql_cache=false)*/
- table1.col_varchar_10__undef_signed AS field1
+ table1.col_int_undef_signed AS field1
FROM rqg_t1 AS table1
LEFT JOIN rqg_t1 AS table2
ON table2.pk = table2.pk
@@ -1024,7 +1024,7 @@ suite("test_local_shuffle_rqg_bugs") {
enable_share_hash_table_for_broadcast_join=false,
enable_broadcast_join_force_passthrough=true,
enable_parallel_scan=false)*/
- table1.col_varchar_10__undef_signed AS field1
+ table1.col_int_undef_signed AS field1
FROM rqg_t1 AS table1
LEFT JOIN rqg_t1 AS table2
ON table2.pk = table2.pk
@@ -1054,7 +1054,7 @@ suite("test_local_shuffle_rqg_bugs") {
def bug19_baseline = sql """
SELECT /*+SET_VAR(enable_local_shuffle_planner=false,
enable_sql_cache=false)*/
- table1.col_varchar_10__undef_signed AS field1
+ table1.col_int_undef_signed AS field1
FROM rqg_t1 AS table1
LEFT JOIN rqg_t1 AS table2
ON table2.pk = table2.pk
@@ -1074,7 +1074,7 @@ suite("test_local_shuffle_rqg_bugs") {
enable_broadcast_join_force_passthrough=false,
enable_parallel_scan=true,
disable_streaming_preaggregations=true)*/
- table1.col_varchar_10__undef_signed AS field1
+ table1.col_int_undef_signed AS field1
FROM rqg_t1 AS table1
LEFT JOIN rqg_t1 AS table2
ON table2.pk = table2.pk
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]