diff --git a/store/tikv/backoff.go b/store/tikv/backoff.go index 256322641f1e7..f3830c4d99f33 100644 --- a/store/tikv/backoff.go +++ b/store/tikv/backoff.go @@ -17,6 +17,7 @@ import ( "context" "fmt" "math" + "math/rand" "strings" "sync/atomic" "time" @@ -27,7 +28,6 @@ import ( "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/metrics" "github.com/pingcap/tidb/util/execdetails" - "github.com/pingcap/tidb/util/fastrand" "github.com/pingcap/tidb/util/logutil" "github.com/prometheus/client_golang/prometheus" "go.uber.org/zap" @@ -94,12 +94,12 @@ func NewBackoffFn(base, cap, jitter int) func(ctx context.Context, maxSleepMs in sleep = expo(base, cap, attempts) case FullJitter: v := expo(base, cap, attempts) - sleep = int(fastrand.Uint32N(uint32(v))) + sleep = rand.Intn(v) case EqualJitter: v := expo(base, cap, attempts) - sleep = v/2 + int(fastrand.Uint32N(uint32(v/2))) + sleep = v/2 + rand.Intn(v/2) case DecorrJitter: - sleep = int(math.Min(float64(cap), float64(base+int(fastrand.Uint32N(uint32(lastSleep*3-base)))))) + sleep = int(math.Min(float64(cap), float64(base+rand.Intn(lastSleep*3-base)))) } logutil.BgLogger().Debug("backoff", zap.Int("base", base), diff --git a/store/tikv/kv.go b/store/tikv/kv.go index fa3c1ebe0ced3..c28cfd2c54508 100644 --- a/store/tikv/kv.go +++ b/store/tikv/kv.go @@ -35,7 +35,6 @@ import ( "github.com/pingcap/tidb/store/tikv/oracle/oracles" "github.com/pingcap/tidb/store/tikv/tikvrpc" "github.com/pingcap/tidb/util/execdetails" - "github.com/pingcap/tidb/util/fastrand" "github.com/pingcap/tidb/util/logutil" pd "github.com/tikv/pd/client" "go.etcd.io/etcd/clientv3" @@ -212,7 +211,7 @@ func newTikvStore(uuid string, pdClient pd.Client, spkv SafePointKV, client Clie safePoint: 0, spTime: time.Now(), closed: make(chan struct{}), - replicaReadSeed: fastrand.Uint32(), + replicaReadSeed: rand.Uint32(), memCache: kv.NewCacheDB(), } store.lockResolver = newLockResolver(store)