Skip to content

Commit

Permalink
use enhanced wg
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer committed Jan 16, 2023
1 parent adb7ad9 commit 77152f9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ type Domain struct {
memoryUsageAlarmHandle *memoryusagealarm.Handle
serverMemoryLimitHandle *servermemorylimit.Handle
// TODO: use Run for each process in future pr
wg *util.WaitGroupEnhancedWrapper
ewg *util.WaitGroupEnhancedWrapper
wg util.WaitGroupWrapper
statsUpdating atomicutil.Int32
cancel context.CancelFunc
indexUsageSyncLease time.Duration
Expand Down Expand Up @@ -890,6 +891,7 @@ func (do *Domain) Close() {
do.cancel()
}
do.wg.Wait()
do.ewg.Wait()
do.sysSessionPool.Close()
variable.UnregisterStatistics(do.bindHandle.Load())
if do.onClose != nil {
Expand Down Expand Up @@ -919,7 +921,7 @@ func NewDomain(store kv.Storage, ddlLease time.Duration, statsLease time.Duratio
jobsIdsMap: make(map[int64]string),
},
}
do.wg = util.NewWaitGroupEnhancedWrapper("domain", do.exit)
do.ewg = util.NewWaitGroupEnhancedWrapper("domain", do.exit)
do.SchemaValidator = NewSchemaValidator(ddlLease, do)
do.expensiveQueryHandle = expensivequery.NewExpensiveQueryHandle(do.exit)
do.memoryUsageAlarmHandle = memoryusagealarm.NewMemoryUsageAlarmHandle(do.exit)
Expand Down Expand Up @@ -1066,7 +1068,7 @@ func (do *Domain) Init(
// Local store needs to get the change information for every DDL state in each session.
go do.loadSchemaInLoop(ctx, ddlLease)
}
do.wg.Run(do.mdlCheckLoop, "mdlCheckLoop")
do.wg.Run(do.mdlCheckLoop)
do.wg.Add(3)
go do.topNSlowQueryLoop()
go do.infoSyncerKeeper()
Expand Down Expand Up @@ -1108,7 +1110,7 @@ func (do *Domain) initLogBackup(ctx context.Context, pdClient pd.Client) error {
if err != nil {
return err
}
do.wg.Run(loop, "logBackupAdvancer")
do.wg.Run(loop)
return nil
}

Expand Down Expand Up @@ -1922,7 +1924,7 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
do.ddl.RegisterStatsHandle(statsHandle)
// Negative stats lease indicates that it is in test, it does not need update.
if do.statsLease >= 0 {
do.wg.Run(do.loadStatsWorker, "loadStatsWorker")
do.ewg.Run(do.loadStatsWorker, "loadStatsWorker")
}
owner := do.newOwnerManager(handle.StatsPrompt, handle.StatsOwnerKey)
if do.indexUsageSyncLease > 0 {
Expand All @@ -1933,9 +1935,9 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
return nil
}
do.SetStatsUpdating(true)
do.wg.Run(func() { do.updateStatsWorker(ctx, owner) }, "updateStatsWorker")
do.wg.Run(func() { do.autoAnalyzeWorker(owner) }, "autoAnalyzeWorker")
do.wg.Run(func() { do.gcAnalyzeHistory(owner) }, "gcAnalyzeHistory")
do.wg.Run(func() { do.updateStatsWorker(ctx, owner) })
do.wg.Run(func() { do.autoAnalyzeWorker(owner) })
do.wg.Run(func() { do.gcAnalyzeHistory(owner) })
return nil
}

Expand Down

0 comments on commit 77152f9

Please sign in to comment.