diff --git a/go/hack/runtime.go b/go/hack/runtime.go index 83428504818..74bce583a84 100644 --- a/go/hack/runtime.go +++ b/go/hack/runtime.go @@ -46,6 +46,3 @@ func Atof64(s string) (float64, int, error) //go:linkname Atof32 strconv.atof32 func Atof32(s string) (float32, int, error) - -//go:linkname FastRand runtime.fastrand -func FastRand() uint32 diff --git a/go/pools/smartconnpool/pool.go b/go/pools/smartconnpool/pool.go index 7c10d6ba4b0..a4317dc8447 100644 --- a/go/pools/smartconnpool/pool.go +++ b/go/pools/smartconnpool/pool.go @@ -18,12 +18,12 @@ package smartconnpool import ( "context" + "math/rand/v2" "slices" "sync" "sync/atomic" "time" - "vitess.io/vitess/go/hack" "vitess.io/vitess/go/vt/log" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/servenv" @@ -373,8 +373,7 @@ func (pool *ConnPool[D]) extendedMaxLifetime() time.Duration { if maxLifetime == 0 { return 0 } - extended := hack.FastRand() % uint32(maxLifetime) - return time.Duration(maxLifetime) + time.Duration(extended) + return time.Duration(maxLifetime) + time.Duration(rand.Uint32N(uint32(maxLifetime))) } func (pool *ConnPool[C]) connReopen(ctx context.Context, dbconn *Pooled[C], now time.Time) error {