diff --git a/pkg/executor/analyze.go b/pkg/executor/analyze.go index 14d4296d370ba..b581c34d12dfa 100644 --- a/pkg/executor/analyze.go +++ b/pkg/executor/analyze.go @@ -469,10 +469,6 @@ func (e *AnalyzeExec) handleResultsErrorWithConcurrency(ctx context.Context, sta panicCnt := 0 var err error for panicCnt < statsConcurrency { - if err := e.Ctx().GetSessionVars().SQLKiller.HandleSignal(); err != nil { - close(saveResultsCh) - return err - } results, ok := <-resultsCh if !ok { break diff --git a/pkg/planner/core/exhaust_physical_plans.go b/pkg/planner/core/exhaust_physical_plans.go index aae131ebfc9f0..9df94a7869b89 100644 --- a/pkg/planner/core/exhaust_physical_plans.go +++ b/pkg/planner/core/exhaust_physical_plans.go @@ -229,7 +229,9 @@ func GetMergeJoin(p *LogicalJoin, prop *property.PhysicalProperty, schema *expre p.SCtx().GetSessionVars().StmtCtx.SetHintWarning( "Some MERGE_JOIN and NO_MERGE_JOIN hints conflict, NO_MERGE_JOIN is ignored") } - + if !p.SCtx().GetSessionVars().InRestrictedSQL { + fmt.Println("check here") + } // If TiDB_SMJ hint is existed, it should consider enforce merge join, // because we can't trust lhsChildProperty completely. if (p.PreferJoinType&h.PreferMergeJoin) > 0 || @@ -424,7 +426,9 @@ func getHashJoins(p *LogicalJoin, prop *property.PhysicalProperty) (joins []base joins = append(joins, getHashJoin(p, prop, 0, false)) } } - + if !p.SCtx().GetSessionVars().InRestrictedSQL { + fmt.Println("fuck") + } forced = (p.PreferJoinType&h.PreferHashJoin > 0) || forceLeftToBuild || forceRightToBuild shouldSkipHashJoin := shouldSkipHashJoin(p) if !forced && shouldSkipHashJoin { @@ -434,6 +438,9 @@ func getHashJoins(p *LogicalJoin, prop *property.PhysicalProperty) (joins []base "A conflict between the HASH_JOIN hint and the NO_HASH_JOIN hint, " + "or the tidb_opt_enable_hash_join system variable, the HASH_JOIN hint will take precedence.") } + if !p.SCtx().GetSessionVars().InRestrictedSQL { + logutil.BgLogger().Info("not bug", zap.Any("joins", joins)) + } return } @@ -2432,6 +2439,10 @@ func (p *LogicalJoin) ExhaustPhysicalPlans(prop *property.PhysicalProperty) ([]b } if !p.isNAAJ() { + if !p.SCtx().GetSessionVars().InRestrictedSQL { + fmt.Println("wwz") + } + logutil.BgLogger().Info("fuckfuck") // naaj refuse merge join and index join. mergeJoins := GetMergeJoin(p, prop, p.Schema(), p.StatsInfo(), p.Children()[0].StatsInfo(), p.Children()[1].StatsInfo()) if (p.PreferJoinType&h.PreferMergeJoin) > 0 && len(mergeJoins) > 0 { diff --git a/pkg/planner/core/find_best_task.go b/pkg/planner/core/find_best_task.go index 932a05dbd0e03..b68c943867d84 100644 --- a/pkg/planner/core/find_best_task.go +++ b/pkg/planner/core/find_best_task.go @@ -162,6 +162,9 @@ func rebuildChildTasks(p *logicalop.BaseLogicalPlan, childTasks *[]base.Task, pp } *childTasks = append(*childTasks, childTask) } + if len(*childTasks) == 0 { + fmt.Println("fuckyou") + } return nil } @@ -183,13 +186,14 @@ func enumeratePhysicalPlans4Task( if _, ok := p.Self().(*LogicalSequence); ok { iteration = iterateChildPlan4LogicalSequence } - if !p.SCtx().GetSessionVars().InRestrictedSQL { - fmt.Println("fuck") - } for _, pp := range physicalPlans { timeStampNow := p.GetLogicalTS4TaskMap() savedPlanID := p.SCtx().GetSessionVars().PlanID.Load() - + if !p.SCtx().GetSessionVars().InRestrictedSQL { + if len(childTasks) == 1 && childTasks[0] == nil { + logutil.BgLogger().Info("before fuck enumeratePhysicalPlans4Task", zap.Int("len child task", len(childTasks))) + } + } childTasks, curCntPlan, childCnts, err = iteration(p, pp, childTasks, childCnts, prop, opt) if err != nil { return nil, 0, err @@ -199,7 +203,11 @@ func enumeratePhysicalPlans4Task( if len(childTasks) != p.ChildLen() { continue } - + if !p.SCtx().GetSessionVars().InRestrictedSQL { + if len(childTasks) == 1 && childTasks[0] == nil { + logutil.BgLogger().Info("fuck enumeratePhysicalPlans4Task", zap.Int("len child task", len(childTasks))) + } + } // If the target plan can be found in this physicalPlan(pp), rebuild childTasks to build the corresponding combination. if planCounter.IsForce() && int64(*planCounter) <= curCntPlan { p.SCtx().GetSessionVars().PlanID.Store(savedPlanID) @@ -209,6 +217,11 @@ func enumeratePhysicalPlans4Task( return nil, 0, err } } + if !p.SCtx().GetSessionVars().InRestrictedSQL { + if len(childTasks) == 1 && childTasks[0] == nil { + logutil.BgLogger().Info("fuck enumeratePhysicalPlans4Task after ", zap.Int("len child task", len(childTasks))) + } + } // Combine the best child tasks with parent physical plan. curTask := pp.Attach2Task(childTasks...) @@ -261,22 +274,42 @@ func iteratePhysicalPlan4BaseLogical( ) ([]base.Task, int64, []int64, error) { // Find best child tasks firstly. childTasks = childTasks[:0] + if !p.SCtx().GetSessionVars().InRestrictedSQL { + fmt.Println("check") + } // The curCntPlan records the number of possible plans for pp curCntPlan := int64(1) for j, child := range p.Children() { + //if child == nil { + // logutil.BgLogger().Info("WTF") + //} + //if child.ExplainInfo() == "" { + // logutil.BgLogger().Info("WTF") + //} childProp := selfPhysicalPlan.GetChildReqProps(j) + //if !p.SCtx().GetSessionVars().InRestrictedSQL { + //logutil.BgLogger().Info("fuck child", zap.String("child.ExplainInfo()", child.ExplainInfo())) + //} + if _, ok := child.(*LogicalCTETable); ok { + fmt.Println("here") + } childTask, cnt, err := child.FindBestTask(childProp, &PlanCounterDisabled, opt) childCnts[j] = cnt if err != nil { return nil, 0, childCnts, err } + if childTask == nil { + fmt.Println("???????") + } curCntPlan = curCntPlan * cnt if childTask != nil && childTask.Invalid() { return nil, 0, childCnts, nil } childTasks = append(childTasks, childTask) } - + if len(childTasks) == 1 && childTasks[0] == nil { + logutil.BgLogger().Info("iteratePhysicalPlan4BaseLogical meet bug") + } // This check makes sure that there is no invalid child task. if len(childTasks) != p.ChildLen() { return nil, 0, childCnts, nil @@ -528,6 +561,9 @@ func findBestTask(lp base.LogicalPlan, prop *property.PhysicalProperty, planCoun var hintWorksWithProp bool // Maybe the plan can satisfy the required property, // so we try to get the task without the enforced sort first. + if !lp.SCtx().GetSessionVars().InRestrictedSQL { + fmt.Println("here") + } plansFitsProp, hintWorksWithProp, err = p.Self().ExhaustPhysicalPlans(newProp) if err != nil { return nil, 0, err @@ -2917,7 +2953,7 @@ func findBestTask4LogicalCTE(p *LogicalCTE, prop *property.PhysicalProperty, cou func findBestTask4LogicalCTETable(p *LogicalCTETable, prop *property.PhysicalProperty, _ *base.PlanCounterTp, _ *optimizetrace.PhysicalOptimizeOp) (t base.Task, cntPlan int64, err error) { if !prop.IsSortItemEmpty() { - return nil, 1, nil + return base.InvalidTask, 0, nil } pcteTable := PhysicalCTETable{IDForStorage: p.IDForStorage}.Init(p.SCtx(), p.StatsInfo()) diff --git a/pkg/planner/core/issuetest/BUILD.bazel b/pkg/planner/core/issuetest/BUILD.bazel index 41e03b9c6d4e3..f8b7ae77aeb3c 100644 --- a/pkg/planner/core/issuetest/BUILD.bazel +++ b/pkg/planner/core/issuetest/BUILD.bazel @@ -10,6 +10,7 @@ go_test( data = glob(["testdata/**"]), flaky = True, race = "on", + shard_count = 3, deps = [ "//pkg/parser", "//pkg/planner", diff --git a/pkg/planner/core/issuetest/planner_issue_test.go b/pkg/planner/core/issuetest/planner_issue_test.go index a496b649e94ac..5792a77bf2a3f 100644 --- a/pkg/planner/core/issuetest/planner_issue_test.go +++ b/pkg/planner/core/issuetest/planner_issue_test.go @@ -117,4 +117,5 @@ WHERE FROM w );`) + tk.MustQuery(`show warnings`).Check(testkit.Rows()) } diff --git a/pkg/planner/core/optimizer.go b/pkg/planner/core/optimizer.go index 2e42de856ee38..a292d65f98b4c 100644 --- a/pkg/planner/core/optimizer.go +++ b/pkg/planner/core/optimizer.go @@ -1073,9 +1073,6 @@ func physicalOptimize(logic base.LogicalPlan, planCounter *base.PlanCounterTp) ( } }() } - if !logic.SCtx().GetSessionVars().InRestrictedSQL { - fmt.Println("fuck") - } logic.SCtx().GetSessionVars().StmtCtx.TaskMapBakTS = 0 t, _, err := logic.FindBestTask(prop, planCounter, opt) if err != nil { diff --git a/pkg/planner/core/task.go b/pkg/planner/core/task.go index b24ac5abddcab..5779ad5d8759b 100644 --- a/pkg/planner/core/task.go +++ b/pkg/planner/core/task.go @@ -1089,14 +1089,14 @@ func (p *PhysicalUnionAll) Attach2Task(tasks ...base.Task) base.Task { // Attach2Task implements PhysicalPlan interface. func (sel *PhysicalSelection) Attach2Task(tasks ...base.Task) base.Task { - if tasks[0] == nil { - fmt.Println("fuck") - } if mppTask, _ := tasks[0].(*MppTask); mppTask != nil { // always push to mpp task. if expression.CanExprsPushDown(GetPushDownCtx(sel.SCtx()), sel.Conditions, kv.TiFlash) { return attachPlan2Task(sel, mppTask.Copy()) } } + if tasks[0] == nil { + fmt.Println("fuck") + } t := tasks[0].ConvertToRootTask(sel.SCtx()) return attachPlan2Task(sel, t) } diff --git a/pkg/server/main_test.go b/pkg/server/main_test.go index 84840e2d7b0b5..806182bc61e8f 100644 --- a/pkg/server/main_test.go +++ b/pkg/server/main_test.go @@ -63,6 +63,7 @@ func TestMain(m *testing.M) { opts := []goleak.Option{ goleak.IgnoreTopFunction("github.com/dgraph-io/ristretto.(*defaultPolicy).processItems"), + goleak.IgnoreTopFunction("github.com/dgraph-io/ristretto.(*Cache).processItems"), goleak.IgnoreTopFunction("github.com/golang/glog.(*fileSink).flushDaemon"), goleak.IgnoreTopFunction("github.com/bazelbuild/rules_go/go/tools/bzltestutil.RegisterTimeoutHandler.func1"), goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"),