aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-11-05 00:03:13 -0700
committerChris Lu <chris.lu@gmail.com>2021-11-05 00:03:13 -0700
commit7348d2ae6398387bb96526f1d3d9f6fcafc3d4da (patch)
treeb34f5aa15f294db0462e2b837a5d41bb49a5ede0
parent00ae965d8d72cddf8bce279b059b0ff7a960c040 (diff)
downloadseaweedfs-7348d2ae6398387bb96526f1d3d9f6fcafc3d4da.tar.xz
seaweedfs-7348d2ae6398387bb96526f1d3d9f6fcafc3d4da.zip
randomize traffic if replicated
-rw-r--r--weed/filer/filechunk_manifest.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go
index 32008271b..023d9e04a 100644
--- a/weed/filer/filechunk_manifest.go
+++ b/weed/filer/filechunk_manifest.go
@@ -6,6 +6,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/wdclient"
"io"
"math"
+ "math/rand"
"net/url"
"strings"
"time"
@@ -142,6 +143,9 @@ func retriedStreamFetchChunkData(writer io.Writer, urlStrings []string, cipherKe
var shouldRetry bool
var 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 int