Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#49844
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
AilinKid authored and ti-chi-bot committed Dec 28, 2023
1 parent 20c3e7d commit ae3016d
Show file tree
Hide file tree
Showing 4 changed files with 861 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/planner/core/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ func enforceProperty(p *property.PhysicalProperty, tsk task, ctx sessionctx.Cont
}
tsk = mpp.enforceExchanger(p)
}
if p.IsSortItemEmpty() || tsk.plan() == nil {
// when task is double cop task warping a index merge reader, tsk.plan() may be nil when indexPlanFinished is marked
// as false, while the real plan is in idxMergePartPlans. tsk.plan()==nil is not right here.
if p.IsSortItemEmpty() || tsk.invalid() {
return tsk
}
if p.TaskTp != property.MppTaskType {
Expand Down
4 changes: 3 additions & 1 deletion pkg/planner/core/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type copTask struct {
}

func (t *copTask) invalid() bool {
return t.tablePlan == nil && t.indexPlan == nil
return t.tablePlan == nil && t.indexPlan == nil && len(t.idxMergePartPlans) == 0
}

func (t *rootTask) invalid() bool {
Expand All @@ -120,6 +120,8 @@ func (t *copTask) copy() task {
return &nt
}

// copTask plan should be careful with indexMergeReader, whose real plan is stored in
// idxMergePartPlans, when its indexPlanFinished is marked with false.
func (t *copTask) plan() PhysicalPlan {
if t.indexPlanFinished {
return t.tablePlan
Expand Down
Loading

0 comments on commit ae3016d

Please sign in to comment.