Repository navigation
fix(scheduler): give unsplittable UNION ALL branches a stage of their own under the adaptive planner - #2914
Draft
NoahKusaba wants to merge 1 commit into
Draft
fix(scheduler): give unsplittable UNION ALL branches a stage of their own under the adaptive planner#2914NoahKusaba wants to merge 1 commit into
NoahKusaba wants to merge 1 commit into
Conversation
… own under the adaptive planner When a union's stage is split between tasks, each task restricts the branches other tasks own to no partitions. A branch that merges its input into one partition, such as a sort, a global aggregate or a LIMIT, keeps its partition however its inputs are restricted, so every task would run it. apache#2852 made the scheduler run such a stage as one task; the static planner has always given such a branch a stage of its own. DistributedExchangeRule now does the same, asking the same question as the static planner (branch_splits) of each branch as its stage's tasks would see it, with its exchanges replaced by their readers. A branch over an exchange that hasn't run is judged in a later pass, before the union's stage can start. A union whose branches are all stage boundaries now counts as a boundary itself, so a merge or coalesce above it reads the branches directly instead of through a stage that would only copy them. With the planners covering every such branch, remove the one-task fallback: the union check and its packing in bind_one, the cache on RunningStage, the resolver carried on JobInfoCache, and the #[non_exhaustive] markers those fields needed. Restriction still refuses a task whose union branch keeps partitions, as a backstop.
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.
Which issue does this PR close?
Closes #2854.
Rationale for this change
When a union's stage is split between tasks, each task restricts the
UnionExecbranches other tasks own to no partitions. A branch that merges its input into one partition (aSortExecfrom anORDER BY, a global aggregate, aLIMIT) keeps its one partition however its inputs are restricted, so every task would run it. #2852 stopped the wrong rows by running such a stage as one task, which costs parallelism. The static planner has always avoided the problem by giving such a branch a stage of its own (can_stay_inline, #2184). The adaptive planner had no equivalent.Restriction can't fix this per task. Emptying the whole branch changes the task plan's node count, and emptying only its leaves still leaves a global aggregate's
count = 0row. So the boundary has to be placed when the plan is made.What changes are included in this PR?
DistributedExchangeRulestages unsplittable union branches. EachUnionExecbranch is put tobranch_splits, the same test the static planner uses, as the stage's tasks would see it: its exchanges replaced by their readers (BallistaAdapter::with_readers). A branch that fails gets anExchangeExec. A branch over an exchange that hasn't run is judged in a later pass, once its reader can be built. The union's stage can't start before then, and a replan follows every finished stage. The rule's other arms already wait the same way.ORDER BYover a union whose branches were all cut got a union stage that only copied its readers into another shuffle for the merge.is_stage_boundarynow counts aUnionExecwhose branches are all boundaries, and the coalesce and null-aware probe arms use it as well, in place of their bareExchangeExecchecks. No existing plan changes.bind_one, the cache onRunningStage, the resolver carried onJobInfoCache, and the#[non_exhaustive]markers those fields needed.cluster/mod.rsis back to its state before fix(scheduler): fix split UNION ALL stages over custom sources or with merging branches #2852.ensure_branch_restrictedstays as a backstop: should a planner leave such a branch in the union's stage, the task is refused rather than return rows twice.branch_splitsloses its resolver parameter, since both callers pass none.Tests:
UNION ALLof global aggregates, and ofORDER BYover aUNION ALLof one-partition branches (3 stages, the merge reading both sorted branches).split_union.rsalready runs the merging-branch queries adaptively at 1 and 2 partitions per task. Before this PR, 7 of its union stages were run as one task. With it there are none, and none hit the backstop error.Are there any user-facing changes?
Under the adaptive planner, a
UNION ALLbranch that merges its input now gets a stage of its own. The union's stage splits between tasks again, instead of running as one task that ignoresballista.scheduler.max_partitions_per_task. Each such branch adds a stage, which runs in parallel with the others. The 56.0.0 upgrade note and the resolver docs inextending-components.mdare updated accordingly.Some cases behave differently from #2852:
replan_rulesrun afterDistributedExchangeRule. A rule that puts a node that keeps its own partition count into a union branch now hits the backstop error when the stage is split, instead of the stage running as one task.No public API changes compared with 55.0.0.
JobInfoCacheandRunningStageare as they were before #2852, which was going to change them in 56.0.0.