Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

change math/rand => math/rand/v2 in volume_layout.go where is a perfo… (#6006)

dsd3b840c20e3c6
diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go
index 6105027697..55827f314e 100644
--- a/weed/topology/volume_layout.go
+++ b/weed/topology/volume_layout.go
@@ -2,12 +2,13 @@ package topology
import (
"fmt"
- "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
- "math/rand"
+ "math/rand/v2"
"sync"
"sync/atomic"
"time"
+ "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
+
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/glog"
@@ -304,7 +305,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes)
}
if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" {
- vid := vl.writables[rand.Intn(lenWriters)]
+ vid := vl.writables[rand.IntN(lenWriters)]
locationList = vl.vid2location[vid]
if locationList == nil || len(locationList.list) == 0 {
return 0, 0, nil, false, fmt.Errorf("Strangely vid %s is on no machine!", vid.String())