Skip to content

Commit

Permalink
domain: move UpdateStatsHealthyMetrics into updateStatsWorker (#55386)
Browse files Browse the repository at this point in the history
ref #54552
  • Loading branch information
hawkingrei authored Sep 25, 2024
1 parent 2838cd6 commit 0d5e0e9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2444,10 +2444,8 @@ func (do *Domain) loadStatsWorker() {
lease = 3 * time.Second
}
loadTicker := time.NewTicker(lease)
updStatsHealthyTicker := time.NewTicker(20 * lease)
defer func() {
loadTicker.Stop()
updStatsHealthyTicker.Stop()
logutil.BgLogger().Info("loadStatsWorker exited.")
}()

Expand All @@ -2470,8 +2468,6 @@ func (do *Domain) loadStatsWorker() {
if err != nil {
logutil.BgLogger().Debug("load histograms failed", zap.Error(err))
}
case <-updStatsHealthyTicker.C:
statsHandle.UpdateStatsHealthyMetrics()
case <-do.exit:
return
}
Expand Down Expand Up @@ -2545,13 +2541,15 @@ func (do *Domain) updateStatsWorker(_ sessionctx.Context, owner owner.Manager) {
deltaUpdateTicker := time.NewTicker(20*lease + randDuration)
gcStatsTicker := time.NewTicker(100 * lease)
dumpColStatsUsageTicker := time.NewTicker(100 * lease)
updateStatsHealthyTicker := time.NewTicker(20 * lease)
readMemTicker := time.NewTicker(memory.ReadMemInterval)
statsHandle := do.StatsHandle()
defer func() {
dumpColStatsUsageTicker.Stop()
gcStatsTicker.Stop()
deltaUpdateTicker.Stop()
readMemTicker.Stop()
updateStatsHealthyTicker.Stop()
do.SetStatsUpdating(false)
logutil.BgLogger().Info("updateStatsWorker exited.")
}()
Expand Down Expand Up @@ -2581,9 +2579,10 @@ func (do *Domain) updateStatsWorker(_ sessionctx.Context, owner owner.Manager) {
if err != nil {
logutil.BgLogger().Debug("dump column stats usage failed", zap.Error(err))
}

case <-readMemTicker.C:
memory.ForceReadMemStats()
case <-updateStatsHealthyTicker.C:
statsHandle.UpdateStatsHealthyMetrics()
}
}
}
Expand Down

0 comments on commit 0d5e0e9

Please sign in to comment.