mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-27 20:59:42 +08:00
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>
This commit is contained in:
parent
3b840c20e3
commit
151f2ff7a9
@ -3,12 +3,13 @@ package weed_server
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/seaweedfs/seaweedfs/weed/stats"
|
|
||||||
"math/rand/v2"
|
"math/rand/v2"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/seaweedfs/seaweedfs/weed/stats"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/topology"
|
"github.com/seaweedfs/seaweedfs/weed/topology"
|
||||||
|
|
||||||
"github.com/seaweedfs/raft"
|
"github.com/seaweedfs/raft"
|
||||||
@ -42,7 +43,13 @@ func (ms *MasterServer) DoAutomaticVolumeGrow(req *topology.VolumeGrowRequest) {
|
|||||||
func (ms *MasterServer) ProcessGrowRequest() {
|
func (ms *MasterServer) ProcessGrowRequest() {
|
||||||
go func() {
|
go func() {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
firstRun := true
|
||||||
for {
|
for {
|
||||||
|
if firstRun {
|
||||||
|
firstRun = false
|
||||||
|
} else {
|
||||||
|
time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second)
|
||||||
|
}
|
||||||
if !ms.Topo.IsLeader() {
|
if !ms.Topo.IsLeader() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -84,7 +91,6 @@ func (ms *MasterServer) ProcessGrowRequest() {
|
|||||||
glog.V(0).Infof("volume grow request failed: %+v", err)
|
glog.V(0).Infof("volume grow request failed: %+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second)
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user