-
Notifications
You must be signed in to change notification settings - Fork 4k
branch-4.2: [fix](local shuffle) address all receiver instances for a non-serial exchange #65348 #68187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+132
−5
Closed
branch-4.2: [fix](local shuffle) address all receiver instances for a non-serial exchange #65348 #68187
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 120 additions & 0 deletions
120
...apache/doris/nereids/trees/plans/distribute/DistributePlannerReceiverDestinationTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| // 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. | ||
|
|
||
| package org.apache.doris.nereids.trees.plans.distribute; | ||
|
|
||
| import org.apache.doris.nereids.StatementContext; | ||
| import org.apache.doris.nereids.trees.plans.distribute.worker.DistributedPlanWorker; | ||
| import org.apache.doris.nereids.trees.plans.distribute.worker.job.AssignedJob; | ||
| import org.apache.doris.nereids.trees.plans.distribute.worker.job.LocalShuffleAssignedJob; | ||
| import org.apache.doris.planner.ExchangeNode; | ||
| import org.apache.doris.planner.PlanFragment; | ||
| import org.apache.doris.qe.ConnectContext; | ||
|
|
||
| import com.google.common.collect.Lists; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Verifies that DistributePlanner picks the receiver instances a remote sender addresses | ||
| * based on whether the exchange is serial on BE -- not on whether the receiver fragment | ||
| * happens to use local shuffle. | ||
| * | ||
| * A non-serial exchange runs a live receiver on every instance, so the sender must address | ||
| * them all. Funneling such an exchange to the first instance per worker leaves the other | ||
| * instances waiting forever for an EOS that no sender sends (query hangs until timeout). | ||
| */ | ||
| public class DistributePlannerReceiverDestinationTest { | ||
|
|
||
| private DistributePlanner newPlanner() { | ||
| List<PlanFragment> noFragments = Lists.newArrayList(); | ||
| return new DistributePlanner(Mockito.mock(StatementContext.class), noFragments, false, false); | ||
| } | ||
|
|
||
| private AssignedJob instanceOn(DistributedPlanWorker worker) { | ||
| LocalShuffleAssignedJob instance = Mockito.mock(LocalShuffleAssignedJob.class); | ||
| Mockito.when(instance.getAssignedWorker()).thenReturn(worker); | ||
| return instance; | ||
| } | ||
|
|
||
| private ExchangeNode exchange(boolean serialOnBe, boolean rightChildOfBroadcastJoin) { | ||
| ExchangeNode node = Mockito.mock(ExchangeNode.class); | ||
| Mockito.when(node.isSerialOperatorOnBe(Mockito.nullable(ConnectContext.class))).thenReturn(serialOnBe); | ||
| Mockito.when(node.isRightChildOfBroadcastHashJoin()).thenReturn(rightChildOfBroadcastJoin); | ||
| return node; | ||
| } | ||
|
|
||
| private PipelineDistributedPlan receiverWith(List<AssignedJob> instances) { | ||
| PipelineDistributedPlan plan = Mockito.mock(PipelineDistributedPlan.class); | ||
| Mockito.when(plan.getInstanceJobs()).thenReturn(instances); | ||
| return plan; | ||
| } | ||
|
|
||
| @Test | ||
| public void nonSerialExchangeAddressesEveryReceiverInstance() { | ||
| // 4 receiver instances across 2 workers (e.g. a bucket-to-hash upgraded fragment) | ||
| DistributedPlanWorker w0 = Mockito.mock(DistributedPlanWorker.class); | ||
| DistributedPlanWorker w1 = Mockito.mock(DistributedPlanWorker.class); | ||
| AssignedJob i0 = instanceOn(w0); | ||
| AssignedJob i1 = instanceOn(w0); | ||
| AssignedJob i2 = instanceOn(w1); | ||
| AssignedJob i3 = instanceOn(w1); | ||
| List<AssignedJob> all = Lists.newArrayList(i0, i1, i2, i3); | ||
|
|
||
| List<AssignedJob> destinations = newPlanner().filterInstancesWhichCanReceiveDataFromRemote( | ||
| receiverWith(all), false, exchange(false, false)); | ||
|
|
||
| // Non-serial exchange: every instance owns a live receiver, so all must be addressed. | ||
| Assertions.assertEquals(all, destinations); | ||
| } | ||
|
|
||
| @Test | ||
| public void serialExchangeFunnelsToFirstInstancePerWorker() { | ||
| DistributedPlanWorker w0 = Mockito.mock(DistributedPlanWorker.class); | ||
| DistributedPlanWorker w1 = Mockito.mock(DistributedPlanWorker.class); | ||
| AssignedJob i0 = instanceOn(w0); | ||
| AssignedJob i1 = instanceOn(w0); | ||
| AssignedJob i2 = instanceOn(w1); | ||
| AssignedJob i3 = instanceOn(w1); | ||
| List<AssignedJob> all = Lists.newArrayList(i0, i1, i2, i3); | ||
|
|
||
| List<AssignedJob> destinations = newPlanner().filterInstancesWhichCanReceiveDataFromRemote( | ||
| receiverWith(all), false, exchange(true, false)); | ||
|
|
||
| // Serial exchange: BE runs a single receiver per worker, funnel to the first instance. | ||
| Assertions.assertEquals(Lists.newArrayList(i0, i2), destinations); | ||
| } | ||
|
|
||
| @Test | ||
| public void broadcastShareHashTableFunnelsEvenWhenNonSerial() { | ||
| DistributedPlanWorker w0 = Mockito.mock(DistributedPlanWorker.class); | ||
| DistributedPlanWorker w1 = Mockito.mock(DistributedPlanWorker.class); | ||
| AssignedJob i0 = instanceOn(w0); | ||
| AssignedJob i1 = instanceOn(w0); | ||
| AssignedJob i2 = instanceOn(w1); | ||
| List<AssignedJob> all = Lists.newArrayList(i0, i1, i2); | ||
|
|
||
| List<AssignedJob> destinations = newPlanner().filterInstancesWhichCanReceiveDataFromRemote( | ||
| receiverWith(all), true, exchange(false, true)); | ||
|
|
||
| // Shared-hash-table broadcast build still funnels one build per worker. | ||
| Assertions.assertEquals(Lists.newArrayList(i0, i2), destinations); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Pass the branch's fifth constructor argument
DistributePlannerhas only the five-argument constructor(StatementContext, List<PlanFragment>, boolean, boolean, boolean)on this branch, so this new four-argument call cannot compile and none of these regression assertions can run. Please pass the missinguseLoadBackendSelectionvalue (falsefor this isolated test).