From 151f2ff7a9f551e713ff9894348a9bac138d5247 Mon Sep 17 00:00:00 2001 From: dsd <60881537+dsd2077@users.noreply.github.com> Date: Thu, 12 Sep 2024 01:24:52 +0800 Subject: [PATCH] prevent dead loop for followers of master node (#6007) * prevent dead loop for followers of master node * fix comments --------- Co-authored-by: levi <344887649@foxmail.com> --- weed/server/master_grpc_server_volume.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.go index 6d5ee0385..e2e6cda42 100644 --- a/weed/server/master_grpc_server_volume.go +++ b/weed/server/master_grpc_server_volume.go @@ -3,12 +3,13 @@ package weed_server import ( "context" "fmt" - "github.com/seaweedfs/seaweedfs/weed/stats" "math/rand/v2" "strings" "sync" "time" + "github.com/seaweedfs/seaweedfs/weed/stats" + "github.com/seaweedfs/seaweedfs/weed/topology" "github.com/seaweedfs/raft" @@ -42,7 +43,13 @@ func (ms *MasterServer) DoAutomaticVolumeGrow(req *topology.VolumeGrowRequest) { func (ms *MasterServer) ProcessGrowRequest() { go func() { ctx := context.Background() + firstRun := true for { + if firstRun { + firstRun = false + } else { + time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second) + } if !ms.Topo.IsLeader() { continue } @@ -84,7 +91,6 @@ func (ms *MasterServer) ProcessGrowRequest() { glog.V(0).Infof("volume grow request failed: %+v", err) } } - time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second) } }() go func() {