aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/master.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/weed/command/master.go b/weed/command/master.go
index 6ef511742..908299c8a 100644
--- a/weed/command/master.go
+++ b/weed/command/master.go
@@ -206,11 +206,13 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
if !*m.raftHashicorp {
go func() {
time.Sleep(timeSleep)
- if ms.Topo.RaftServer.Leader() == "" && ms.Topo.RaftServer.IsLogEmpty() && isTheFirstOne(myMasterAddress, peers) {
- if ms.MasterClient.FindLeaderFromOtherPeers(myMasterAddress) == "" {
- raftServer.DoJoinCommand()
- }
+
+ ms.Topo.RaftServerAccessLock.RLock()
+ isEmptyMaster := ms.Topo.RaftServer.Leader() == "" && ms.Topo.RaftServer.IsLogEmpty()
+ if isEmptyMaster && isTheFirstOne(myMasterAddress, peers) && ms.MasterClient.FindLeaderFromOtherPeers(myMasterAddress) == "" {
+ raftServer.DoJoinCommand()
}
+ ms.Topo.RaftServerAccessLock.RUnlock()
}()
}