Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#58739
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
hawkingrei authored and ti-chi-bot committed Jan 7, 2025
1 parent b47b6e3 commit 6753b5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
LabelGCWorker = "gcworker"
LabelAnalyze = "analyze"
LabelWorkerPool = "worker-pool"
LabelStats = "stats"

LabelBatchRecvLoop = "batch-recv-loop"
LabelBatchSendLoop = "batch-send-loop"
Expand Down
5 changes: 5 additions & 0 deletions pkg/statistics/handle/usage/session_stats_collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func (s *statsUsageImpl) needDumpStatsDelta(is infoschema.InfoSchema, dumpAll bo
// DumpStatsDeltaToKV sweeps the whole list and updates the global map, then we dumps every table that held in map to KV.
// If the mode is `DumpDelta`, it will only dump that delta info that `Modify Count / Table Count` greater than a ratio.
func (s *statsUsageImpl) DumpStatsDeltaToKV(dumpAll bool) error {
defer util.Recover(metrics.LabelStats, "DumpStatsDeltaToKV", nil, false)
start := time.Now()
defer func() {
dur := time.Since(start)
Expand Down Expand Up @@ -219,9 +220,13 @@ func (s *statsUsageImpl) dumpTableStatCountToKV(is infoschema.InfoSchema, physic

// DumpColStatsUsageToKV sweeps the whole list, updates the column stats usage map and dumps it to KV.
func (s *statsUsageImpl) DumpColStatsUsageToKV() error {
<<<<<<< HEAD
if !variable.EnableColumnTracking.Load() {
return nil
}
=======
defer util.Recover(metrics.LabelStats, "DumpColStatsUsageToKV", nil, false)
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
s.SweepSessionStatsList()
colMap := s.SessionStatsUsage().GetUsageAndReset()
defer func() {
Expand Down
5 changes: 5 additions & 0 deletions pkg/statistics/handle/util/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ go_library(
deps = [
"//pkg/infoschema",
"//pkg/kv",
<<<<<<< HEAD
"//pkg/parser/ast",
"//pkg/parser/model",
=======
"//pkg/meta/model",
"//pkg/metrics",
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
"//pkg/parser/terror",
"//pkg/sessionctx",
"//pkg/sessionctx/variable",
Expand Down
10 changes: 10 additions & 0 deletions pkg/statistics/handle/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/pkg/kv"
<<<<<<< HEAD
"github.com/pingcap/tidb/pkg/parser/ast"
=======
"github.com/pingcap/tidb/pkg/meta/model"
"github.com/pingcap/tidb/pkg/metrics"
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
"github.com/pingcap/tidb/pkg/parser/terror"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
Expand Down Expand Up @@ -82,7 +87,12 @@ var (
)

// CallWithSCtx allocates a sctx from the pool and call the f().
<<<<<<< HEAD
func CallWithSCtx(pool SessionPool, f func(sctx sessionctx.Context) error, flags ...int) (err error) {
=======
func CallWithSCtx(pool util.SessionPool, f func(sctx sessionctx.Context) error, flags ...int) (err error) {
defer util.Recover(metrics.LabelStats, "CallWithSCtx", nil, false)
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
se, err := pool.Get()
if err != nil {
return err
Expand Down

0 comments on commit 6753b5c

Please sign in to comment.