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

*: replace mathutil.Max/Min with built-in max/min #47939

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 4 additions & 5 deletions pkg/ddl/backfilling_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/pingcap/tidb/pkg/util/dbterror"
"github.com/pingcap/tidb/pkg/util/intest"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
decoder "github.com/pingcap/tidb/pkg/util/rowDecoder"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -175,7 +174,7 @@ func initSessCtx(

func (*txnBackfillScheduler) expectedWorkerSize() (size int) {
workerCnt := int(variable.GetDDLReorgWorkerCounter())
return mathutil.Min(workerCnt, maxBackfillWorkerSize)
return min(workerCnt, maxBackfillWorkerSize)
}

func (b *txnBackfillScheduler) currentWorkerSize() int {
Expand Down Expand Up @@ -465,9 +464,9 @@ func (*ingestBackfillScheduler) expectedWorkerSize() (readerSize int, writerSize

func expectedIngestWorkerCnt() (readerCnt, writerCnt int) {
workerCnt := int(variable.GetDDLReorgWorkerCounter())
readerCnt = mathutil.Min(workerCnt/2, maxBackfillWorkerSize)
readerCnt = mathutil.Max(readerCnt, 1)
writerCnt = mathutil.Min(workerCnt/2+2, maxBackfillWorkerSize)
readerCnt = min(workerCnt/2, maxBackfillWorkerSize)
readerCnt = max(readerCnt, 1)
writerCnt = min(workerCnt/2+2, maxBackfillWorkerSize)
return readerCnt, writerCnt
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func getLowerBoundInt(partCols ...*model.ColumnInfo) int64 {
if mysql.HasUnsignedFlag(col.FieldType.GetFlag()) {
return 0
}
ret = mathutil.Min(ret, types.IntergerSignedLowerBound(col.GetType()))
ret = min(ret, types.IntergerSignedLowerBound(col.GetType()))
}
return ret
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/sequence.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func handleSequenceOptions(seqOptions []*ast.SequenceOption, sequenceInfo *model
sequenceInfo.MaxValue = model.DefaultNegativeSequenceMaxValue
}
if !startSetFlag {
sequenceInfo.Start = mathutil.Min(sequenceInfo.MaxValue, model.DefaultNegativeSequenceStartValue)
sequenceInfo.Start = min(sequenceInfo.MaxValue, model.DefaultNegativeSequenceStartValue)
}
if !minSetFlag {
sequenceInfo.MinValue = model.DefaultNegativeSequenceMinValue
Expand Down
1 change: 0 additions & 1 deletion pkg/distsql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ go_test(
"//pkg/util/collate",
"//pkg/util/disk",
"//pkg/util/execdetails",
"//pkg/util/mathutil",
"//pkg/util/memory",
"//pkg/util/mock",
"//pkg/util/paging",
Expand Down
5 changes: 2 additions & 3 deletions pkg/distsql/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/pingcap/tidb/pkg/util/codec"
"github.com/pingcap/tidb/pkg/util/disk"
"github.com/pingcap/tidb/pkg/util/execdetails"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/mock"
"github.com/pingcap/tipb/go-tipb"
Expand Down Expand Up @@ -228,7 +227,7 @@ func (resp *mockResponse) Next(context.Context) (kv.ResultSubset, error) {
if resp.count >= resp.total {
return nil, nil
}
numRows := mathutil.Min(resp.batch, resp.total-resp.count)
numRows := min(resp.batch, resp.total-resp.count)
resp.count += numRows

var chunks []tipb.Chunk
Expand All @@ -245,7 +244,7 @@ func (resp *mockResponse) Next(context.Context) (kv.ResultSubset, error) {
} else {
chunks = make([]tipb.Chunk, 0)
for numRows > 0 {
rows := mathutil.Min(numRows, 1024)
rows := min(numRows, 1024)
numRows -= rows

colTypes := make([]*types.FieldType, 4)
Expand Down
1 change: 0 additions & 1 deletion pkg/infoschema/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ go_library(
"//pkg/util/domainutil",
"//pkg/util/execdetails",
"//pkg/util/logutil",
"//pkg/util/mathutil",
"//pkg/util/mock",
"//pkg/util/pdapi",
"//pkg/util/sem",
Expand Down
7 changes: 3 additions & 4 deletions pkg/infoschema/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/pingcap/tidb/pkg/table/tables"
"github.com/pingcap/tidb/pkg/util/domainutil"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -420,9 +419,9 @@ func updateAutoIDForExchangePartition(store kv.Storage, ptSchemaID, ptID, ntSche

// Set both tables to the maximum auto IDs between normal table and partitioned table.
newAutoIDs := meta.AutoIDGroup{
RowID: mathutil.Max(ptAutoIDs.RowID, ntAutoIDs.RowID),
IncrementID: mathutil.Max(ptAutoIDs.IncrementID, ntAutoIDs.IncrementID),
RandomID: mathutil.Max(ptAutoIDs.RandomID, ntAutoIDs.RandomID),
RowID: max(ptAutoIDs.RowID, ntAutoIDs.RowID),
IncrementID: max(ptAutoIDs.IncrementID, ntAutoIDs.IncrementID),
RandomID: max(ptAutoIDs.RandomID, ntAutoIDs.RandomID),
}
err = t.GetAutoIDAccessors(ptSchemaID, ptID).Put(newAutoIDs)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/meta/autoid/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ go_library(
"//pkg/util/etcd",
"//pkg/util/execdetails",
"//pkg/util/logutil",
"//pkg/util/mathutil",
"//pkg/util/tracing",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
Expand Down
25 changes: 12 additions & 13 deletions pkg/meta/autoid/autoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/pingcap/tidb/pkg/util/etcd"
"github.com/pingcap/tidb/pkg/util/execdetails"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/tracing"
"github.com/tikv/client-go/v2/txnkv/txnsnapshot"
tikvutil "github.com/tikv/client-go/v2/util"
Expand Down Expand Up @@ -353,8 +352,8 @@ func (alloc *allocator) rebase4Unsigned(ctx context.Context, requiredBase uint64
}
uCurrentEnd := uint64(currentEnd)
if allocIDs {
newBase = mathutil.Max(uCurrentEnd, requiredBase)
newEnd = mathutil.Min(math.MaxUint64-uint64(alloc.step), newBase) + uint64(alloc.step)
newBase = max(uCurrentEnd, requiredBase)
newEnd = min(math.MaxUint64-uint64(alloc.step), newBase) + uint64(alloc.step)
} else {
if uCurrentEnd >= requiredBase {
newBase = uCurrentEnd
Expand Down Expand Up @@ -412,8 +411,8 @@ func (alloc *allocator) rebase4Signed(ctx context.Context, requiredBase int64, a
return err1
}
if allocIDs {
newBase = mathutil.Max(currentEnd, requiredBase)
newEnd = mathutil.Min(math.MaxInt64-alloc.step, newBase) + alloc.step
newBase = max(currentEnd, requiredBase)
newEnd = min(math.MaxInt64-alloc.step, newBase) + alloc.step
} else {
if currentEnd >= requiredBase {
newBase = currentEnd
Expand Down Expand Up @@ -872,7 +871,7 @@ func SeekToFirstAutoIDUnSigned(base, increment, offset uint64) uint64 {
return nr
}

func (alloc *allocator) alloc4Signed(ctx context.Context, n uint64, increment, offset int64) (min int64, max int64, err error) {
func (alloc *allocator) alloc4Signed(ctx context.Context, n uint64, increment, offset int64) (mini int64, max int64, err error) {
// Check offset rebase if necessary.
if offset-1 > alloc.base {
if err := alloc.rebase4Signed(ctx, offset-1, true); err != nil {
Expand Down Expand Up @@ -926,7 +925,7 @@ func (alloc *allocator) alloc4Signed(ctx context.Context, n uint64, increment, o
if nextStep < n1 {
nextStep = n1
}
tmpStep := mathutil.Min(math.MaxInt64-newBase, nextStep)
tmpStep := min(math.MaxInt64-newBase, nextStep)
// The global rest is not enough for alloc.
if tmpStep < n1 {
return ErrAutoincReadFailed
Expand All @@ -953,12 +952,12 @@ func (alloc *allocator) alloc4Signed(ctx context.Context, n uint64, increment, o
zap.Uint64("to ID", uint64(alloc.base+n1)),
zap.Int64("table ID", alloc.tbID),
zap.Int64("database ID", alloc.dbID))
min = alloc.base
mini = alloc.base
alloc.base += n1
return min, alloc.base, nil
return mini, alloc.base, nil
}

func (alloc *allocator) alloc4Unsigned(ctx context.Context, n uint64, increment, offset int64) (min int64, max int64, err error) {
func (alloc *allocator) alloc4Unsigned(ctx context.Context, n uint64, increment, offset int64) (mini int64, max int64, err error) {
// Check offset rebase if necessary.
if uint64(offset-1) > uint64(alloc.base) {
if err := alloc.rebase4Unsigned(ctx, uint64(offset-1), true); err != nil {
Expand Down Expand Up @@ -1017,7 +1016,7 @@ func (alloc *allocator) alloc4Unsigned(ctx context.Context, n uint64, increment,
if nextStep < n1 {
nextStep = n1
}
tmpStep := int64(mathutil.Min(math.MaxUint64-uint64(newBase), uint64(nextStep)))
tmpStep := int64(min(math.MaxUint64-uint64(newBase), uint64(nextStep)))
// The global rest is not enough for alloc.
if tmpStep < n1 {
return ErrAutoincReadFailed
Expand All @@ -1044,10 +1043,10 @@ func (alloc *allocator) alloc4Unsigned(ctx context.Context, n uint64, increment,
zap.Uint64("to ID", uint64(alloc.base+n1)),
zap.Int64("table ID", alloc.tbID),
zap.Int64("database ID", alloc.dbID))
min = alloc.base
mini = alloc.base
// Use uint64 n directly.
alloc.base = int64(uint64(alloc.base) + uint64(n1))
return min, alloc.base, nil
return mini, alloc.base, nil
}

func getAllocatorStatsFromCtx(ctx context.Context) (context.Context, *AllocatorRuntimeStats, **tikvutil.CommitDetails) {
Expand Down
1 change: 0 additions & 1 deletion pkg/metrics/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ go_library(
"//pkg/parser/terror",
"//pkg/timer/metrics",
"//pkg/util/logutil",
"//pkg/util/mathutil",
"//pkg/util/promutil",
"@com_github_pingcap_errors//:errors",
"@com_github_prometheus_client_golang//prometheus",
Expand Down
5 changes: 2 additions & 3 deletions pkg/metrics/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package metrics

import (
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/prometheus/client_golang/prometheus"
dto "github.com/prometheus/client_model/go"
)
Expand Down Expand Up @@ -402,7 +401,7 @@ func (c TablePartitionUsageCounter) Cal(rhs TablePartitionUsageCounter) TablePar
TablePartitionRangeColumnsGt2Cnt: c.TablePartitionRangeColumnsGt2Cnt - rhs.TablePartitionRangeColumnsGt2Cnt,
TablePartitionRangeColumnsGt3Cnt: c.TablePartitionRangeColumnsGt3Cnt - rhs.TablePartitionRangeColumnsGt3Cnt,
TablePartitionListColumnsCnt: c.TablePartitionListColumnsCnt - rhs.TablePartitionListColumnsCnt,
TablePartitionMaxPartitionsCnt: mathutil.Max(c.TablePartitionMaxPartitionsCnt-rhs.TablePartitionMaxPartitionsCnt, rhs.TablePartitionMaxPartitionsCnt),
TablePartitionMaxPartitionsCnt: max(c.TablePartitionMaxPartitionsCnt-rhs.TablePartitionMaxPartitionsCnt, rhs.TablePartitionMaxPartitionsCnt),
TablePartitionCreateIntervalPartitionsCnt: c.TablePartitionCreateIntervalPartitionsCnt - rhs.TablePartitionCreateIntervalPartitionsCnt,
TablePartitionAddIntervalPartitionsCnt: c.TablePartitionAddIntervalPartitionsCnt - rhs.TablePartitionAddIntervalPartitionsCnt,
TablePartitionDropIntervalPartitionsCnt: c.TablePartitionDropIntervalPartitionsCnt - rhs.TablePartitionDropIntervalPartitionsCnt,
Expand All @@ -423,7 +422,7 @@ func ResetTablePartitionCounter(pre TablePartitionUsageCounter) TablePartitionUs
TablePartitionRangeColumnsGt2Cnt: readCounter(TelemetryTablePartitionRangeColumnsGt2Cnt),
TablePartitionRangeColumnsGt3Cnt: readCounter(TelemetryTablePartitionRangeColumnsGt3Cnt),
TablePartitionListColumnsCnt: readCounter(TelemetryTablePartitionListColumnsCnt),
TablePartitionMaxPartitionsCnt: mathutil.Max(readCounter(TelemetryTablePartitionMaxPartitionsCnt)-pre.TablePartitionMaxPartitionsCnt, pre.TablePartitionMaxPartitionsCnt),
TablePartitionMaxPartitionsCnt: max(readCounter(TelemetryTablePartitionMaxPartitionsCnt)-pre.TablePartitionMaxPartitionsCnt, pre.TablePartitionMaxPartitionsCnt),
TablePartitionReorganizePartitionCnt: readCounter(TelemetryReorganizePartitionCnt),
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/privilege/privileges/privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -984,15 +984,15 @@ func (passwordLocking *PasswordLocking) ParseJSON(passwordLockingJSON types.Bina
if err != nil {
return err
}
passwordLocking.FailedLoginAttempts = mathutil.Min(passwordLocking.FailedLoginAttempts, math.MaxInt16)
passwordLocking.FailedLoginAttempts = min(passwordLocking.FailedLoginAttempts, math.MaxInt16)
passwordLocking.FailedLoginAttempts = mathutil.Max(passwordLocking.FailedLoginAttempts, 0)

passwordLocking.PasswordLockTimeDays, err =
extractInt64FromJSON(passwordLockingJSON, "$.Password_locking.password_lock_time_days")
if err != nil {
return err
}
passwordLocking.PasswordLockTimeDays = mathutil.Min(passwordLocking.PasswordLockTimeDays, math.MaxInt16)
passwordLocking.PasswordLockTimeDays = min(passwordLocking.PasswordLockTimeDays, math.MaxInt16)
passwordLocking.PasswordLockTimeDays = mathutil.Max(passwordLocking.PasswordLockTimeDays, -1)

passwordLocking.FailedLoginCount, err =
Expand Down
1 change: 0 additions & 1 deletion pkg/resourcemanager/pool/spool/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ go_library(
"//pkg/resourcemanager/poolmanager",
"//pkg/resourcemanager/util",
"//pkg/util/logutil",
"//pkg/util/mathutil",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_sasha_s_go_deadlock//:go-deadlock",
"@org_uber_go_zap//:zap",
Expand Down
3 changes: 1 addition & 2 deletions pkg/resourcemanager/pool/spool/spool.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/pingcap/tidb/pkg/resourcemanager/poolmanager"
"github.com/pingcap/tidb/pkg/resourcemanager/util"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/prometheus/client_golang/prometheus"
"github.com/sasha-s/go-deadlock"
"go.uber.org/zap"
Expand Down Expand Up @@ -197,7 +196,7 @@ func (p *Pool) checkAndAddRunningInternal(concurrency int32) (conc int32, run bo
}
// if concurrency is 1 , we must return a goroutine
// if concurrency is more than 1, we must return at least one goroutine.
result := mathutil.Min(n, concurrency)
result := min(n, concurrency)
p.running.Add(result)
return result, true
}
Expand Down
1 change: 0 additions & 1 deletion pkg/session/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ go_library(
"//pkg/util/kvcache",
"//pkg/util/logutil",
"//pkg/util/logutil/consistency",
"//pkg/util/mathutil",
"//pkg/util/memory",
"//pkg/util/parser",
"//pkg/util/sem",
Expand Down
3 changes: 1 addition & 2 deletions pkg/session/nontransactional.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/pingcap/tidb/pkg/util/collate"
"github.com/pingcap/tidb/pkg/util/dbterror"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/sqlexec"
"go.uber.org/zap"
Expand Down Expand Up @@ -850,5 +849,5 @@ func buildExecuteResults(ctx context.Context, jobs []job, maxChunkSize int, reda
zap.Int("num_failed_jobs", len(failedJobs)), zap.String("failed_jobs", errStr))

return nil, fmt.Errorf("%d/%d jobs failed in the non-transactional DML: %s, ...(more in logs)",
len(failedJobs), len(jobs), errStr[:mathutil.Min(500, len(errStr)-1)])
len(failedJobs), len(jobs), errStr[:min(500, len(errStr)-1)])
}
3 changes: 1 addition & 2 deletions pkg/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ import (
"github.com/pingcap/tidb/pkg/util/kvcache"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/logutil/consistency"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/sem"
"github.com/pingcap/tidb/pkg/util/sli"
Expand Down Expand Up @@ -1742,7 +1741,7 @@ func (s *session) ParseWithParams(ctx context.Context, sql string, args ...inter
}
if err != nil {
s.rollbackOnError(ctx)
logSQL := sql[:mathutil.Min(500, len(sql))]
logSQL := sql[:min(500, len(sql))]
if s.sessionVars.EnableRedactLog {
logutil.Logger(ctx).Debug("parse SQL failed", zap.Error(err), zap.String("SQL", logSQL))
} else {
Expand Down
1 change: 0 additions & 1 deletion pkg/store/copr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ go_library(
"//pkg/util/execdetails",
"//pkg/util/intest",
"//pkg/util/logutil",
"//pkg/util/mathutil",
"//pkg/util/memory",
"//pkg/util/paging",
"//pkg/util/tiflash",
Expand Down
3 changes: 1 addition & 2 deletions pkg/store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import (
util2 "github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/execdetails"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/paging"
"github.com/pingcap/tidb/pkg/util/tracing"
Expand Down Expand Up @@ -377,7 +376,7 @@ func buildCopTasks(bo *Backoffer, ranges *KeyRanges, opt *buildCopTaskOpt) ([]*c
pagingSize = req.Paging.MinPagingSize
}
for i := 0; i < rLen; {
nextI := mathutil.Min(i+rangesPerTaskLimit, rLen)
nextI := min(i+rangesPerTaskLimit, rLen)
hint := -1
// calculate the row count hint
if hints != nil {
Expand Down
3 changes: 1 addition & 2 deletions pkg/store/copr/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/pingcap/tidb/pkg/store/driver/backoff"
"github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/pingcap/tidb/pkg/util/tiflash"
"github.com/pingcap/tidb/pkg/util/tiflashcompute"
"github.com/tikv/client-go/v2/tikv"
Expand Down Expand Up @@ -174,7 +173,7 @@ func (c *MPPClient) DispatchMPPTask(param kv.DispatchMPPTaskParam) (resp *mpp.Di
}

if len(realResp.RetryRegions) > 0 {
logutil.BgLogger().Info("TiFlash found " + strconv.Itoa(len(realResp.RetryRegions)) + " stale regions. Only first " + strconv.Itoa(mathutil.Min(10, len(realResp.RetryRegions))) + " regions will be logged if the log level is higher than Debug")
logutil.BgLogger().Info("TiFlash found " + strconv.Itoa(len(realResp.RetryRegions)) + " stale regions. Only first " + strconv.Itoa(min(10, len(realResp.RetryRegions))) + " regions will be logged if the log level is higher than Debug")
for index, retry := range realResp.RetryRegions {
id := tikv.NewRegionVerID(retry.Id, retry.RegionEpoch.ConfVer, retry.RegionEpoch.Version)
if index < 10 || log.GetLevel() <= zap.DebugLevel {
Expand Down
3 changes: 1 addition & 2 deletions pkg/store/copr/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
derr "github.com/pingcap/tidb/pkg/store/driver/error"
"github.com/pingcap/tidb/pkg/store/driver/options"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/mathutil"
"github.com/tikv/client-go/v2/metrics"
"github.com/tikv/client-go/v2/tikv"
"go.uber.org/zap"
Expand Down Expand Up @@ -202,7 +201,7 @@ func (c *RegionCache) OnSendFailForBatchRegions(bo *Backoffer, store *tikv.Store
logutil.Logger(bo.GetCtx()).Info("Should not reach here, OnSendFailForBatchRegions only support TiFlash")
return
}
logutil.Logger(bo.GetCtx()).Info("Send fail for " + strconv.Itoa(len(regionInfos)) + " regions, will switch region peer for these regions. Only first " + strconv.Itoa(mathutil.Min(10, len(regionInfos))) + " regions will be logged if the log level is higher than Debug")
logutil.Logger(bo.GetCtx()).Info("Send fail for " + strconv.Itoa(len(regionInfos)) + " regions, will switch region peer for these regions. Only first " + strconv.Itoa(min(10, len(regionInfos))) + " regions will be logged if the log level is higher than Debug")
for index, ri := range regionInfos {
if ri.Meta == nil {
continue
Expand Down
1 change: 0 additions & 1 deletion pkg/store/mockstore/unistore/tikv/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ go_library(
"//pkg/tablecodec",
"//pkg/types",
"//pkg/util/codec",
"//pkg/util/mathutil",
"//pkg/util/rowcodec",
"@com_github_dgryski_go_farm//:go-farm",
"@com_github_gogo_protobuf//proto",
Expand Down
Loading