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
commit 491003d2c9a49f95eb379643024ef8f93163c784 Author: 924060929 <[email protected]> AuthorDate: Tue Apr 14 23:19:12 2026 +0800 [fix](local shuffle) Fix NLJ childUsePoolingScan: use useSerialSource without hasSerialScanNode gate The hasSerialScanNode() gate excluded fragments with serial Exchanges but no ScanNode (e.g., receive fragments with NLJ). In pooling mode these fragments still need BROADCAST on the build side — without it, probe tasks only see partial build data, causing row count mismatch in GROUPING SETS + subquery queries on 4+ BE clusters. Reverts the overly strict check introduced in the enforceRequire refactoring. --- .../org/apache/doris/planner/NestedLoopJoinNode.java | 8 +++----- .../doris/planner/LocalShuffleNodeCoverageTest.java | 2 -- .../test_local_shuffle_fe_be_consistency.groovy | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java index d9395e7c9a4..49915ad5851 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/NestedLoopJoinNode.java @@ -179,11 +179,9 @@ public class NestedLoopJoinNode extends JoinNodeBase { public Pair<PlanNode, LocalExchangeType> enforceAndDeriveLocalExchange(PlanTranslatorContext translatorContext, PlanNode parent, LocalExchangeTypeRequire parentRequire) { - // Pooling scan: useSerialSource() AND actually has a pooling scan node in the fragment. - // Without hasSerialScanNode(), useSerialSource() can be true for fragments with only - // serial Exchanges (use_serial_exchange=true) but no pooling scan, causing false positives. - boolean childUsePoolingScan = fragment.useSerialSource(translatorContext.getConnectContext()) - && fragment.hasSerialScanNode(); + // Pooling mode: the fragment uses serial source (pooling scan or serial exchange). + // NLJ build side needs BROADCAST in pooling mode so all probe tasks see full build data. + boolean childUsePoolingScan = fragment.useSerialSource(translatorContext.getConnectContext()); LocalExchangeTypeRequire probeSideRequire; LocalExchangeTypeRequire buildSideRequire; diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/LocalShuffleNodeCoverageTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/LocalShuffleNodeCoverageTest.java index 23f935091a9..8241f6d4c2a 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/LocalShuffleNodeCoverageTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/LocalShuffleNodeCoverageTest.java @@ -310,8 +310,6 @@ public class LocalShuffleNodeCoverageTest { Lists.newArrayList(new TupleId(NEXT_ID.getAndIncrement())), JoinOperator.INNER_JOIN, false); serialSourceJoin.fragment = Mockito.mock(PlanFragment.class); Mockito.when(serialSourceJoin.fragment.useSerialSource(Mockito.any())).thenReturn(true); - // childUsePoolingScan requires BOTH useSerialSource AND hasSerialScanNode - Mockito.when(serialSourceJoin.fragment.hasSerialScanNode()).thenReturn(true); Pair<PlanNode, LocalExchangeType> serialOutput = serialSourceJoin.enforceAndDeriveLocalExchange( ctx, null, LocalExchangeTypeRequire.noRequire()); Assertions.assertEquals(LocalExchangeType.ADAPTIVE_PASSTHROUGH, serialOutput.second); diff --git a/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_fe_be_consistency.groovy b/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_fe_be_consistency.groovy index 37b5b26ad72..dd83c7e5eab 100644 --- a/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_fe_be_consistency.groovy +++ b/regression-test/suites/nereids_p0/local_shuffle/test_local_shuffle_fe_be_consistency.groovy @@ -911,6 +911,24 @@ suite("test_local_shuffle_fe_be_consistency") { GROUP BY a.k1, b.k1 ORDER BY 1, 2, 3""") + // ============================================================ + // 15. NLJ + GROUPING SETS + subquery + pooling scan (RQG build 187580) + // NLJ build side in a fragment without ScanNode (only Exchange) still needs + // BROADCAST in pooling mode. Previously childUsePoolingScan was gated by + // hasSerialScanNode() which excluded Exchange-only fragments, causing NLJ + // build side to miss BROADCAST → probe tasks see partial build data → wrong results. + // ============================================================ + checkConsistencyWithSql("nlj_grouping_sets_subquery_pooling", + """SELECT ${svSerialSource} COUNT(pk * (SELECT COUNT(pk) FROM ls_t1)) OVER() + FROM ls_t1 + GROUP BY GROUPING SETS ((k1, k2), (), (k1))""") + + // Same pattern but simpler: NLJ with subquery + pooling, no GROUPING SETS + checkConsistencyWithSql("nlj_subquery_pooling", + """SELECT ${svSerialSource} k1, (SELECT COUNT(*) FROM ls_t2) + FROM ls_t1 + ORDER BY k1""") + // ================================================================ // Phase 2: Fetch all profiles and compare results // By now, all queries have been executed and profiles are being --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
