diff options
| author | Patrick Schmidt <patrick.schmidt@innogames.com> | 2022-08-24 18:49:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 09:49:05 -0700 |
| commit | 7b424a54dc56c883a3e03894d924631a4ef7a94c (patch) | |
| tree | 0b98b4dcee9d2294b50282529dab8f1b0aac6a39 /weed/command/master.go | |
| parent | f7e4359b597c9acdb0478c05c6f6ae6fbb56836b (diff) | |
| download | seaweedfs-7b424a54dc56c883a3e03894d924631a4ef7a94c.tar.xz seaweedfs-7b424a54dc56c883a3e03894d924631a4ef7a94c.zip | |
Add raft server access mutex to avoid races (#3503)
Diffstat (limited to 'weed/command/master.go')
| -rw-r--r-- | weed/command/master.go | 10 |
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() }() } |
