Skip to content

Commit

Permalink
ttl: modify default value of tidb_ttl_delete_batch_size to 100 (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
lcwangchao authored and YangKeao committed Dec 20, 2022
1 parent 4c53df4 commit a57de99
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
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

0 comments on commit a57de99

Please sign in to comment.