Skip to content

Commit 2b2f629

Browse files
hawkingreiti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#58739
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 207b06b commit 2b2f629

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

pkg/metrics/metrics.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const (
4545
LabelGCWorker = "gcworker"
4646
LabelAnalyze = "analyze"
4747
LabelWorkerPool = "worker-pool"
48+
LabelStats = "stats"
4849

4950
LabelBatchRecvLoop = "batch-recv-loop"
5051
LabelBatchSendLoop = "batch-send-loop"

pkg/statistics/handle/usage/session_stats_collect.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ func (s *statsUsageImpl) needDumpStatsDelta(is infoschema.InfoSchema, dumpAll bo
8282
// DumpStatsDeltaToKV sweeps the whole list and updates the global map, then we dumps every table that held in map to KV.
8383
// If the mode is `DumpDelta`, it will only dump that delta info that `Modify Count / Table Count` greater than a ratio.
8484
func (s *statsUsageImpl) DumpStatsDeltaToKV(dumpAll bool) error {
85+
defer util.Recover(metrics.LabelStats, "DumpStatsDeltaToKV", nil, false)
8586
start := time.Now()
8687
defer func() {
8788
dur := time.Since(start)
@@ -214,9 +215,13 @@ func (s *statsUsageImpl) dumpTableStatCountToKV(is infoschema.InfoSchema, physic
214215

215216
// DumpColStatsUsageToKV sweeps the whole list, updates the column stats usage map and dumps it to KV.
216217
func (s *statsUsageImpl) DumpColStatsUsageToKV() error {
218+
<<<<<<< HEAD
217219
if !variable.EnableColumnTracking.Load() {
218220
return nil
219221
}
222+
=======
223+
defer util.Recover(metrics.LabelStats, "DumpColStatsUsageToKV", nil, false)
224+
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
220225
s.SweepSessionStatsList()
221226
colMap := s.SessionStatsUsage().GetUsageAndReset()
222227
defer func() {

pkg/statistics/handle/util/BUILD.bazel

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ go_library(
1515
deps = [
1616
"//pkg/infoschema",
1717
"//pkg/kv",
18+
<<<<<<< HEAD
1819
"//pkg/parser/ast",
1920
"//pkg/parser/model",
21+
=======
22+
"//pkg/meta/model",
23+
"//pkg/metrics",
24+
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
2025
"//pkg/parser/terror",
2126
"//pkg/sessionctx",
2227
"//pkg/sessionctx/variable",

pkg/statistics/handle/util/util.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ import (
2222
"github.com/pingcap/errors"
2323
"github.com/pingcap/failpoint"
2424
"github.com/pingcap/tidb/pkg/kv"
25+
<<<<<<< HEAD
2526
"github.com/pingcap/tidb/pkg/parser/ast"
27+
=======
28+
"github.com/pingcap/tidb/pkg/meta/model"
29+
"github.com/pingcap/tidb/pkg/metrics"
30+
>>>>>>> 23ed0dfd6ed (statistics: add recover to protect background task (#58739))
2631
"github.com/pingcap/tidb/pkg/parser/terror"
2732
"github.com/pingcap/tidb/pkg/sessionctx"
2833
"github.com/pingcap/tidb/pkg/sessionctx/variable"
@@ -75,7 +80,12 @@ var (
7580
)
7681

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

0 commit comments

Comments
 (0)