Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttl: modify default value of tidb_ttl_delete_batch_size to 100 (#39878) #39889

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions metrics/grafana/tidb.json
Original file line number Diff line number Diff line change
Expand Up @@ -17528,6 +17528,10 @@
{
"alias": "dispatch",
"color": "#8F3BB8"
},
{
"alias": "wait_token",
"color": "#8AB8FF"
}
],
"spaceLength": 10,
Expand Down Expand Up @@ -17654,6 +17658,10 @@
{
"alias": "dispatch",
"color": "#8F3BB8"
},
{
"alias": "wait_token",
"color": "#8AB8FF"
}
],
"spaceLength": 10,
Expand Down
2 changes: 1 addition & 1 deletion sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ const (
DefTiDBTTLScanBatchSize = 500
DefTiDBTTLScanBatchMaxSize = 10240
DefTiDBTTLScanBatchMinSize = 1
DefTiDBTTLDeleteBatchSize = 500
DefTiDBTTLDeleteBatchSize = 100
DefTiDBTTLDeleteBatchMaxSize = 10240
DefTiDBTTLDeleteBatchMinSize = 1
DefTiDBTTLDeleteRateLimit = 0
Expand Down
2 changes: 2 additions & 0 deletions ttl/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
PhaseCheckTTL = "check_ttl"
PhaseWaitRetry = "wait_retry"
PhaseDispatch = "dispatch"
PhaseWaitToken = "wait_token"
PhaseOther = "other"
)

Expand Down Expand Up @@ -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),
}
}
Expand Down
6 changes: 6 additions & 0 deletions ttl/ttlworker/del.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down