From c7d4c9cebb207bf5bf4dd4e532c44fe9ad753774 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Sun, 7 Apr 2024 15:45:19 +0800 Subject: [PATCH] domon,statistics: remove useless code for sync load (#52358) --- pkg/domain/domain.go | 3 +-- pkg/statistics/handle/syncload/stats_syncload.go | 7 ------- pkg/statistics/handle/types/interfaces.go | 5 ----- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/pkg/domain/domain.go b/pkg/domain/domain.go index 2be5e6d6c1aae..05317ba899ece 100644 --- a/pkg/domain/domain.go +++ b/pkg/domain/domain.go @@ -2243,11 +2243,10 @@ func quitStatsOwner(do *Domain, mgr owner.Manager) { // StartLoadStatsSubWorkers starts sub workers with new sessions to load stats concurrently. func (do *Domain) StartLoadStatsSubWorkers(ctxList []sessionctx.Context) { statsHandle := do.StatsHandle() - for i, ctx := range ctxList { + for _, ctx := range ctxList { // The sync load will affect how optimizer choose the plan. // We need to assign high priority to it so that we can get the stats as quick as we can. ctx.GetSessionVars().StmtCtx.Priority = mysql.HighPriority - statsHandle.SetSubCtxs(i, ctx) do.wg.Add(1) go statsHandle.SubLoadWorker(ctx, do.exit, do.wg) } diff --git a/pkg/statistics/handle/syncload/stats_syncload.go b/pkg/statistics/handle/syncload/stats_syncload.go index 4befd5470f5be..4a7956b1147ae 100644 --- a/pkg/statistics/handle/syncload/stats_syncload.go +++ b/pkg/statistics/handle/syncload/stats_syncload.go @@ -45,7 +45,6 @@ type statsSyncLoad struct { func NewStatsSyncLoad(statsHandle statstypes.StatsHandle) statstypes.StatsSyncLoad { s := &statsSyncLoad{statsHandle: statsHandle} cfg := config.GetGlobalConfig() - s.StatsLoad.SubCtxs = make([]sessionctx.Context, cfg.Performance.StatsLoadConcurrency) s.StatsLoad.NeededItemsCh = make(chan *statstypes.NeededItemTask, cfg.Performance.StatsLoadQueueSize) s.StatsLoad.TimeoutItemsCh = make(chan *statstypes.NeededItemTask, cfg.Performance.StatsLoadQueueSize) return s @@ -58,12 +57,6 @@ type statsWrapper struct { idx *statistics.Index } -// SetSubCtxs sets the sessionctx which is used to run queries background. -// TODO: use SessionPool instead. -func (s *statsSyncLoad) SetSubCtxs(idx int, sctx sessionctx.Context) { - s.StatsLoad.SubCtxs[idx] = sctx -} - // SendLoadRequests send neededColumns requests func (s *statsSyncLoad) SendLoadRequests(sc *stmtctx.StatementContext, neededHistItems []model.StatsLoadItem, timeout time.Duration) error { remainedItems := s.removeHistLoadedColumns(neededHistItems) diff --git a/pkg/statistics/handle/types/interfaces.go b/pkg/statistics/handle/types/interfaces.go index 5bffd2a196327..d3a4ee726306a 100644 --- a/pkg/statistics/handle/types/interfaces.go +++ b/pkg/statistics/handle/types/interfaces.go @@ -398,7 +398,6 @@ type StatsLoad struct { NeededItemsCh chan *NeededItemTask TimeoutItemsCh chan *NeededItemTask Singleflight singleflight.Group - SubCtxs []sessionctx.Context sync.Mutex } @@ -418,10 +417,6 @@ type StatsSyncLoad interface { // HandleOneTask will handle one task. HandleOneTask(sctx sessionctx.Context, lastTask *NeededItemTask, exit chan struct{}) (task *NeededItemTask, err error) - - // SetSubCtxs sets the sessionctx which is used to run queries background. - // TODO: use SessionPool instead. - SetSubCtxs(idx int, sctx sessionctx.Context) } // StatsGlobal is used to manage partition table global stats.