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.

randomize file locations

Chris Lueed492b73b67
diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go
index 74f0375572..2a46c1ca68 100644
--- a/weed/filer/reader_at.go
+++ b/weed/filer/reader_at.go
@@ -3,14 +3,14 @@ package filer
import (
"context"
"fmt"
- "github.com/golang/groupcache/singleflight"
- "io"
- "sync"
-
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util/chunk_cache"
"github.com/chrislusf/seaweedfs/weed/wdclient"
+ "github.com/golang/groupcache/singleflight"
+ "io"
+ "math/rand"
+ "sync"
)
type ChunkReadAt struct {
@@ -64,6 +64,11 @@ func LookupFn(filerClient filer_pb.FilerClient) LookupFileIdFunctionType {
targetUrls = append(targetUrls, targetUrl)
}
+ for i := len(targetUrls) - 1; i > 0; i-- {
+ j := rand.Intn(i + 1)
+ targetUrls[i], targetUrls[j] = targetUrls[j], targetUrls[i]
+ }
+
return
}
}