-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add session property to enforce timeout for query registration in HBO #23354
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,8 @@ | |
| import org.testng.annotations.Test; | ||
|
|
||
| import static com.facebook.presto.SystemSessionProperties.CONFIDENCE_BASED_BROADCAST_ENABLED; | ||
| import static com.facebook.presto.SystemSessionProperties.ENFORCE_HISTORY_BASED_OPTIMIZER_REGISTRATION_TIMEOUT; | ||
| import static com.facebook.presto.SystemSessionProperties.HISTORY_BASED_OPTIMIZER_TIMEOUT_LIMIT; | ||
| import static com.facebook.presto.SystemSessionProperties.HISTORY_CANONICAL_PLAN_NODE_LIMIT; | ||
| import static com.facebook.presto.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE; | ||
| import static com.facebook.presto.SystemSessionProperties.JOIN_REORDERING_STRATEGY; | ||
|
|
@@ -129,6 +131,88 @@ public void testHistoryBasedStatsCalculator() | |
| anyTree(node(AggregationNode.class, node(ExchangeNode.class, anyTree(any()))).withOutputRowCount(3).withOutputSize(54))); | ||
| } | ||
|
|
||
| @Test | ||
| public void testHistoryBasedStatsCalculatorEnforceTimeOut() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks like it tests cases where the timeout is enabled, but never exceeded. Can you add a test case where the timeout gets enforced, eg. you set the timeout really low (like to 0?) and then check that we don't use hbo stats?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added test with time limit to be 0 |
||
| { | ||
| Session sessionWithDefaultTimeoutLimit = Session.builder(createSession()) | ||
| .setSystemProperty(ENFORCE_HISTORY_BASED_OPTIMIZER_REGISTRATION_TIMEOUT, "true") | ||
| .build(); | ||
| Session sessionWithZeroTimeoutLimit = Session.builder(createSession()) | ||
| .setSystemProperty(ENFORCE_HISTORY_BASED_OPTIMIZER_REGISTRATION_TIMEOUT, "true") | ||
| .setSystemProperty(HISTORY_BASED_OPTIMIZER_TIMEOUT_LIMIT, "0ms") | ||
| .build(); | ||
| // CBO Statistics | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT * FROM nation where substr(name, 1, 1) = 'A'", | ||
| anyTree(node(FilterNode.class, any()).withOutputRowCount(Double.NaN))); | ||
|
|
||
| // Write HBO statistics failed as we set timeout limit to be 0 | ||
| executeAndNoHistoryWritten("SELECT * FROM nation where substr(name, 1, 1) = 'A'", sessionWithZeroTimeoutLimit); | ||
| // No HBO statistics read | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT * FROM nation where substr(name, 1, 1) = 'A'", | ||
| anyTree(node(FilterNode.class, any()).withOutputRowCount(Double.NaN))); | ||
|
|
||
| // Write HBO Statistics is successful, as we use the default 10 seconds timeout limit | ||
| executeAndTrackHistory("SELECT * FROM nation where substr(name, 1, 1) = 'A'", sessionWithDefaultTimeoutLimit); | ||
| // Read HBO statistics successfully with default timeout | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT * FROM nation where substr(name, 1, 1) = 'A'", | ||
| anyTree(node(FilterNode.class, any()).withOutputRowCount(2).withOutputSize(199))); | ||
| // Read HBO statistics fail due to timeout | ||
| assertPlan( | ||
| sessionWithZeroTimeoutLimit, | ||
| "SELECT * FROM nation where substr(name, 1, 1) = 'A'", | ||
| anyTree(node(FilterNode.class, any()).withOutputRowCount(Double.NaN))); | ||
|
|
||
| // CBO Statistics | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(ProjectNode.class, node(FilterNode.class, any())).withOutputRowCount(12.5))); | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(AggregationNode.class, node(ExchangeNode.class, anyTree(any()))).withOutputRowCount(Double.NaN))); | ||
|
|
||
| // Write HBO statistics failed as we set timeout limit to be 0 | ||
| executeAndNoHistoryWritten("SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", sessionWithZeroTimeoutLimit); | ||
| // No HBO statistics read | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(ProjectNode.class, node(FilterNode.class, any())).withOutputRowCount(12.5))); | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(AggregationNode.class, node(ExchangeNode.class, anyTree(any()))).withOutputRowCount(Double.NaN))); | ||
|
|
||
| // Write HBO Statistics is successful, as we use the default 10 seconds timeout limit | ||
| executeAndTrackHistory("SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", sessionWithDefaultTimeoutLimit); | ||
| // Read HBO statistics successfully with default timeout | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(ProjectNode.class, node(FilterNode.class, any())).withOutputRowCount(5).withOutputSize(90))); | ||
| assertPlan( | ||
| sessionWithDefaultTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(AggregationNode.class, node(ExchangeNode.class, anyTree(any()))).withOutputRowCount(3).withOutputSize(54))); | ||
|
|
||
| // Read HBO statistics fail due to timeout | ||
| assertPlan( | ||
| sessionWithZeroTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(ProjectNode.class, node(FilterNode.class, any())).withOutputRowCount(12.5))); | ||
| assertPlan( | ||
| sessionWithZeroTimeoutLimit, | ||
| "SELECT max(nationkey) FROM nation where name < 'D' group by regionkey", | ||
| anyTree(node(AggregationNode.class, node(ExchangeNode.class, anyTree(any()))).withOutputRowCount(Double.NaN))); | ||
| } | ||
|
|
||
| @Test | ||
| public void testFailedQuery() | ||
| { | ||
|
|
@@ -525,6 +609,12 @@ private void executeAndTrackHistory(String sql, Session session) | |
| getHistoryProvider().waitProcessQueryEvents(); | ||
| } | ||
|
|
||
| private void executeAndNoHistoryWritten(String sql, Session session) | ||
| { | ||
| getQueryRunner().execute(session, sql); | ||
| getHistoryProvider().noProcessQueryEvents(); | ||
| } | ||
|
|
||
| private InMemoryHistoryBasedPlanStatisticsProvider getHistoryProvider() | ||
| { | ||
| DistributedQueryRunner queryRunner = (DistributedQueryRunner) getQueryRunner(); | ||
|
|
||
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.
semaphore is released during the putStats function call. If HBO failed, there will be no putStats function call, hence we will not get the semaphore here. Use this function to assert the case where HBO timeout