Fix no value present scheduling failure with grouped execution#22538
Merged
rschlussel merged 2 commits intoprestodb:masterfrom Apr 17, 2024
Merged
Fix no value present scheduling failure with grouped execution#22538rschlussel merged 2 commits intoprestodb:masterfrom
rschlussel merged 2 commits intoprestodb:masterfrom
Conversation
85c8225 to
043ec4b
Compare
dca7f13 to
9d7620f
Compare
Member
hantangwangd
left a comment
There was a problem hiding this comment.
Very nice catch, overall looks good to me. A little question for discussing.
Comment on lines
+345
to
+347
| if (plan.getFragment().getRemoteSourceNodes().stream().allMatch(node -> node.getExchangeType() == REPLICATE) | ||
| && schedulingOrder.stream().allMatch(id -> plan.getFragment().getStageExecutionDescriptor().isScanGroupedExecution(id))) { | ||
| // no non-replicated remote source and all scans are grouped |
Member
There was a problem hiding this comment.
A little question, do we need this change? Should a fragment with broadcast-only remote sources but couldn't support dynamic lifespan scheduling still go through this path?
Contributor
Author
There was a problem hiding this comment.
oh, I think you are right that we don't need this! The case you describe does go through here, but the stage execution descriptor won't be dynamicLifespanSchedule, and so we'll get a non-dynamic bucket node map in the code two lines below. Now I see that the else path is for stages that need a nodePartitionMap, which I believe is only needed for a partitioned remote source.
Dynamic lifespan schedule grouped execution assumes all scans are using
grouped execution. Queries like the following can produce a plan where
some scans are grouped and some are ungrouped
SELECT count(*) from bucketed_table1 t1 join (SELECT * FROM bucketed_table2
where some_column in (SELECTk key FROM my_small_broadcast_table) t2 on
t1.key=t2.key group by t1.key;
The relevant would look as follows:
AGGREGATION
|
JOIN
/ \
/ \
TableScan(grouped) SemiJoin
/ \
TableScan(ungrouped) RemoteSource (replicated exchange)
This fixes an error where such queries could fail with a "no value
present" error during node scheduling.
9d7620f to
2c4c693
Compare
arhimondr
approved these changes
Apr 17, 2024
36 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Only use dynamic scheduling if all scans in a stage are using grouped execution
Motivation and Context
Previously queries with a mix of ungrouped and grouped scans in the same fragment could fail with the following stack trace:
Example query shape:
SELECT count(*) from bucketed_table1 t1 join (SELECT * FROM bucketed_table2 where some_column in (SELECTk key FROM my_small_broadcast_table) t2 on t1.key=t2.key group by t1.key;The plan for the relevant fragment would look as follows:
Impact
Fixes a bug with mix of joins and semijoins using grouped execution
Test Plan
Added new test
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.