mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid infinite loop WaitUntilConnected() (#3431)
https://github.com/seaweedfs/seaweedfs/issues/3421
This commit is contained in:
parent
53b601616c
commit
4d4cd0948d
|
@ -276,11 +276,9 @@ func (ms *MasterServer) startAdminScripts() {
|
||||||
go commandEnv.MasterClient.KeepConnectedToMaster()
|
go commandEnv.MasterClient.KeepConnectedToMaster()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
commandEnv.MasterClient.WaitUntilConnected()
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
time.Sleep(time.Duration(sleepMinutes) * time.Minute)
|
time.Sleep(time.Duration(sleepMinutes) * time.Minute)
|
||||||
if ms.Topo.IsLeader() {
|
if ms.Topo.IsLeader() && ms.MasterClient.GetMaster() != "" {
|
||||||
shellOptions.FilerAddress = ms.GetOneFiler(cluster.FilerGroupName(*shellOptions.FilerGroup))
|
shellOptions.FilerAddress = ms.GetOneFiler(cluster.FilerGroupName(*shellOptions.FilerGroup))
|
||||||
if shellOptions.FilerAddress == "" {
|
if shellOptions.FilerAddress == "" {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -93,7 +93,10 @@ func (mc *MasterClient) GetMasters() map[string]pb.ServerAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MasterClient) WaitUntilConnected() {
|
func (mc *MasterClient) WaitUntilConnected() {
|
||||||
for mc.currentMaster == "" {
|
for {
|
||||||
|
if mc.currentMaster != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
time.Sleep(time.Duration(rand.Int31n(200)) * time.Millisecond)
|
time.Sleep(time.Duration(rand.Int31n(200)) * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +138,6 @@ func (mc *MasterClient) FindLeaderFromOtherPeers(myMasterAddress pb.ServerAddres
|
||||||
func (mc *MasterClient) tryAllMasters() {
|
func (mc *MasterClient) tryAllMasters() {
|
||||||
var nextHintedLeader pb.ServerAddress
|
var nextHintedLeader pb.ServerAddress
|
||||||
for _, master := range mc.masters {
|
for _, master := range mc.masters {
|
||||||
|
|
||||||
nextHintedLeader = mc.tryConnectToMaster(master)
|
nextHintedLeader = mc.tryConnectToMaster(master)
|
||||||
for nextHintedLeader != "" {
|
for nextHintedLeader != "" {
|
||||||
nextHintedLeader = mc.tryConnectToMaster(nextHintedLeader)
|
nextHintedLeader = mc.tryConnectToMaster(nextHintedLeader)
|
||||||
|
@ -228,9 +230,7 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
if gprcErr != nil {
|
if gprcErr != nil {
|
||||||
stats.MasterClientConnectCounter.WithLabelValues(stats.Failed).Inc()
|
stats.MasterClientConnectCounter.WithLabelValues(stats.Failed).Inc()
|
||||||
|
|
Loading…
Reference in a new issue