-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Collect HBO stats from complete stages in failed queries #20947
Conversation
1685913
to
ac98cfa
Compare
b267529
to
be0fb46
Compare
looks good, but the property name is pretty long. i wonder if there's a shorter name we could use that would still be clear. |
be0fb46
to
f19608b
Compare
Rename to track_complete_stages_stats_from_failed_query after consulting metamate lol |
@@ -1522,6 +1523,11 @@ public SystemSessionProperties( | |||
"Track history based plan statistics service in query optimizer", | |||
featuresConfig.isTrackHistoryBasedPlanStatistics(), | |||
false), | |||
booleanProperty( | |||
TRACK_COMPLETE_STAGES_STATS_FROM_FAILED_QUERY, |
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.
not sure if we need "COMPLETE_STAGES" as part of the property name - perhaps leave it out and only specify it in the documentation string
another idea would be to turn this property around and make it track_history_from_successful_queries_only
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.
not sure if we need "COMPLETE_STAGES" as part of the property name - perhaps leave it out and only specify it in the documentation string another idea would be to turn this property around and make it track_history_from_successful_queries_only
So session params should be default true to reflect the preferred default behavior for clarity. I prefer true values for session params as default. So I say stick with failed_queries version
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.
I try to avoid words with negative meaning in the flags because it makes it hard to reason about enabling/disabling but it makes sense to leave it as in this case. We would probably only need to disable it if there is a problem with it
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.
+1 for Lyublena's name suggestion. Accepting in advance
0db0c32
f19608b
to
0db0c32
Compare
presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
0db0c32
to
7c8253f
Compare
Codenotify: Notifying subscribers in CODENOTIFY files for diff 58d5767...8db9bad.
|
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.
looks good. just recommend updating the property name to say queries
rather than query
presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/cost/HistoryBasedPlanStatisticsTracker.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/SystemSessionProperties.java
Outdated
Show resolved
Hide resolved
presto-docs/src/main/sphinx/optimizer/history-based-optimization.rst
Outdated
Show resolved
Hide resolved
@@ -812,6 +812,14 @@ Optimizer Properties | |||
Enable analysis and propagation of logical properties (distinct keys, cardinality, etc.) among the nodes of | |||
a query plan. The optimizer may then use these properties to perform various optimizations. | |||
|
|||
``optimizer.track-history-stats-from-failed-query`` |
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.
update documentation if you change the property name
``optimizer.track-history-stats-from-failed-query`` | |
``optimizer.track-history-stats-from-failed-queries`` |
@@ -124,7 +126,7 @@ public Map<PlanNodeWithHash, PlanStatisticsWithSourceInfo> getQueryStats(QueryIn | |||
} | |||
|
|||
StageInfo outputStage = queryInfo.getOutputStage().get(); | |||
List<StageInfo> allStages = outputStage.getAllStages(); | |||
List<StageInfo> allStages = trackStatsForFailedQueries ? outputStage.getAllStages().stream().filter(x -> x.isFinalStageInfo()).collect(toImmutableList()) : outputStage.getAllStages(); |
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.
Did you test that the final stage info is only present stages that succeeded and not for stages that finished with a failure? You may also need to add a check that the stage state is "FINISHED"
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.
Changed condition to check the stage state is FINISHED
Maybe you can add a complete e2e test to run a query with join with build side stats missing with failure of say join but get the stats for the build side and make sure it's stats are recorded? Also make it a test on insert query so we get as close to real life test as possible. |
7c8253f
to
8db9bad
Compare
@Test | ||
public void testFailedQuery() | ||
{ | ||
String sql = "select o.orderkey, l.partkey, l.mapcol[o.orderkey] from (select orderkey, partkey, mapcol from (select *, map(array[1], array[2]) mapcol from lineitem)) l " + |
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.
Join will fail, but the build input will succeed.
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.
maybe add this comment in the test
@Test | ||
public void testFailedQuery() | ||
{ | ||
String sql = "select o.orderkey, l.partkey, l.mapcol[o.orderkey] from (select orderkey, partkey, mapcol from (select *, map(array[1], array[2]) mapcol from lineitem)) l " + |
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.
maybe add this comment in the test
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.
Thanks for writing the e2e test!
This morning I started to see the flake in TestHistoryBasedStatsTracking shown below. Any chance that was caused by this PR? Timing and classes change look suspicious though I don't immediately see the cause.
|
@elharo This PR shouldn't fail this test. Can you share a link to the failed test? |
Description
Record the operator stats if the stage completes, even if the query failed.
Motivation and Context
Currently in HBO, we only record stats if the query is successful. However, even if the query failed, some of its stage can still be successful, and we can store the statistics for these operators.
Impact
More stats available for HBO. It can also apply HBO to previous failed queries, and potentially make failed queries successful.
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.