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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
randomize same-dc servers and other-dc servers
Chris Lu7bf891c00a82
diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.goindex 023d9e04a2..32008271bd 100644--- a/weed/filer/filechunk_manifest.go+++ b/weed/filer/filechunk_manifest.go@@ -6,7 +6,6 @@ import ("github.com/chrislusf/seaweedfs/weed/wdclient""io""math"- "math/rand""net/url""strings""time"@@ -143,9 +142,6 @@ func retriedStreamFetchChunkData(writer io.Writer, urlStrings []string, cipherKevar shouldRetry boolvar totalWritten int- rand.Shuffle(len(urlStrings), func(i, j int) {- urlStrings[i], urlStrings[j] = urlStrings[j], urlStrings[i]- })for waitTime := time.Second; waitTime < util.RetryWaitTime; waitTime += waitTime / 2 {for _, urlString := range urlStrings {var localProcesed intdiff --git a/weed/wdclient/vid_map.go b/weed/wdclient/vid_map.goindex 670d1ad777..e0bea2a019 100644--- a/weed/wdclient/vid_map.go+++ b/weed/wdclient/vid_map.go@@ -4,6 +4,7 @@ import ("errors""fmt""github.com/chrislusf/seaweedfs/weed/pb"+ "math/rand""strconv""strings""sync"@@ -69,13 +70,21 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err erif !found {return nil, fmt.Errorf("volume %d not found", id)}+ var sameDcServers, otherDcServers []stringfor _, loc := range locations {if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter {- serverUrls = append(serverUrls, loc.Url)+ sameDcServers = append(sameDcServers, loc.Url)} else {- serverUrls = append([]string{loc.Url}, serverUrls...)+ otherDcServers = append(otherDcServers, loc.Url)}}+ rand.Shuffle(len(sameDcServers), func(i, j int) {+ sameDcServers[i], sameDcServers[j] = sameDcServers[j], sameDcServers[i]+ })+ rand.Shuffle(len(otherDcServers), func(i, j int) {+ otherDcServers[i], otherDcServers[j] = otherDcServers[j], otherDcServers[i]+ })+ serverUrls = append(sameDcServers, otherDcServers...)return}