From de27e554333ffafea9d6fead29ba08d20fa326bc Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Tue, 13 Dec 2022 16:15:32 +0800 Subject: [PATCH 1/3] ttl: modify default value of `tidb_ttl_delete_batch_size` to 100 --- sessionctx/variable/tidb_vars.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index 92410e617177f..a7e3c167418c9 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -1143,7 +1143,7 @@ const ( DefTiDBTTLScanBatchSize = 500 DefTiDBTTLScanBatchMaxSize = 10240 DefTiDBTTLScanBatchMinSize = 1 - DefTiDBTTLDeleteBatchSize = 500 + DefTiDBTTLDeleteBatchSize = 100 DefTiDBTTLDeleteBatchMaxSize = 10240 DefTiDBTTLDeleteBatchMinSize = 1 DefTiDBTTLDeleteRateLimit = 0 From 5b5410411925f6158e1e5996da30c31c98cc9b6d Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Tue, 13 Dec 2022 17:46:07 +0800 Subject: [PATCH 2/3] update metrics --- ttl/metrics/metrics.go | 2 ++ ttl/ttlworker/del.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ttl/metrics/metrics.go b/ttl/metrics/metrics.go index 6f845932383db..8768b0e267388 100644 --- a/ttl/metrics/metrics.go +++ b/ttl/metrics/metrics.go @@ -31,6 +31,7 @@ var ( PhaseCheckTTL = "check_ttl" PhaseWaitRetry = "wait_retry" PhaseDispatch = "dispatch" + PhaseWaitToken = "wait_token" PhaseOther = "other" ) @@ -58,6 +59,7 @@ func initWorkerPhases(workerType string) map[string]prometheus.Counter { PhaseWaitRetry: metrics.TTLPhaseTime.WithLabelValues(workerType, PhaseWaitRetry), PhaseDispatch: metrics.TTLPhaseTime.WithLabelValues(workerType, PhaseDispatch), PhaseCheckTTL: metrics.TTLPhaseTime.WithLabelValues(workerType, PhaseCheckTTL), + PhaseWaitToken: metrics.TTLPhaseTime.WithLabelValues(workerType, PhaseWaitToken), PhaseOther: metrics.TTLPhaseTime.WithLabelValues(workerType, PhaseOther), } } diff --git a/ttl/ttlworker/del.go b/ttl/ttlworker/del.go index 17769fcc378c9..8f66fb7fad246 100644 --- a/ttl/ttlworker/del.go +++ b/ttl/ttlworker/del.go @@ -86,6 +86,10 @@ type ttlDeleteTask struct { } func (t *ttlDeleteTask) doDelete(ctx context.Context, rawSe session.Session) (retryRows [][]types.Datum) { + tracer := metrics.PhaseTracerFromCtx(ctx) + defer tracer.EnterPhase(tracer.Phase()) + tracer.EnterPhase(metrics.PhaseOther) + leftRows := t.rows se := newTableSession(rawSe, t.tbl, t.expire) for len(leftRows) > 0 { @@ -109,10 +113,12 @@ func (t *ttlDeleteTask) doDelete(ctx context.Context, rawSe session.Session) (re ) } + tracer.EnterPhase(metrics.PhaseWaitToken) if err = globalDelRateLimiter.Wait(ctx); err != nil { t.statistics.IncErrorRows(len(delBatch)) return } + tracer.EnterPhase(metrics.PhaseOther) sqlStart := time.Now() _, needRetry, err := se.ExecuteSQLWithCheck(ctx, sql) From 10f4eb562bc4b9066aef99c3a39fe229a61aa5aa Mon Sep 17 00:00:00 2001 From: Chao Wang Date: Tue, 13 Dec 2022 17:52:45 +0800 Subject: [PATCH 3/3] update --- metrics/grafana/tidb.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metrics/grafana/tidb.json b/metrics/grafana/tidb.json index 2f52a768e0ee7..9d4a451fafca9 100644 --- a/metrics/grafana/tidb.json +++ b/metrics/grafana/tidb.json @@ -17528,6 +17528,10 @@ { "alias": "dispatch", "color": "#8F3BB8" + }, + { + "alias": "wait_token", + "color": "#8AB8FF" } ], "spaceLength": 10, @@ -17654,6 +17658,10 @@ { "alias": "dispatch", "color": "#8F3BB8" + }, + { + "alias": "wait_token", + "color": "#8AB8FF" } ], "spaceLength": 10,