Skip to content
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

Shuffle partitioned instance to avoid skew #1744

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion fe/src/main/java/org/apache/doris/qe/Coordinator.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -111,6 +112,9 @@ public class Coordinator {

private static String localIP = FrontendOptions.getLocalHostAddress();

// Random is used to shuffle instances of partitioned
private static Random instanceRandom = new Random();

// Overall status of the entire query; set to the first reported fragment error
// status or to CANCELLED, if Cancel() is called.
Status queryStatus = new Status();
Expand Down Expand Up @@ -857,7 +861,12 @@ private void computeFragmentHosts() throws Exception {
0, params);
params.instanceExecParams.add(instanceParam);
}


// When group by cardinality is smaller than number of backend, only some backends always
// process while other has no data to process.
// So we shuffle instances to make different backends handle different queries.
Collections.shuffle(params.instanceExecParams, instanceRandom);

// TODO: switch to unpartitioned/coord execution if our input fragment
// is executed that way (could have been downgraded from distributed)
continue;
Expand Down