diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-11-04 09:23:40 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-11-04 09:23:40 -0700 |
| commit | 00ae965d8d72cddf8bce279b059b0ff7a960c040 (patch) | |
| tree | d673ae79aa1a864522f95729162bbfbf51c328a6 /weed/shell/command_ec_encode.go | |
| parent | b485c905d49bb94966a1ebfe58ff158601235112 (diff) | |
| download | seaweedfs-00ae965d8d72cddf8bce279b059b0ff7a960c040.tar.xz seaweedfs-00ae965d8d72cddf8bce279b059b0ff7a960c040.zip | |
randomize a bit for ec shards distribution
Diffstat (limited to 'weed/shell/command_ec_encode.go')
| -rw-r--r-- | weed/shell/command_ec_encode.go | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go index 9a64bb486..3606f42e3 100644 --- a/weed/shell/command_ec_encode.go +++ b/weed/shell/command_ec_encode.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/chrislusf/seaweedfs/weed/pb" "io" + "math/rand" "sync" "time" @@ -248,7 +249,7 @@ func parallelCopyEcShardsFromSource(grpcDialOption grpc.DialOption, targetServer func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) { allocated = make([][]uint32, len(servers)) allocatedShardIdIndex := uint32(0) - serverIndex := 0 + serverIndex := rand.Intn(len(servers)) for allocatedShardIdIndex < erasure_coding.TotalShardsCount { if servers[serverIndex].freeEcSlot > 0 { allocated[serverIndex] = append(allocated[serverIndex], allocatedShardIdIndex) |
