From 70f6740309b12ee3ddbabf7100fb0dcab2c17fe6 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 6 Dec 2017 00:14:14 -0800 Subject: [PATCH] better fix for single master restart without peers changing --- weed/server/raft_server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/server/raft_server.go b/weed/server/raft_server.go index 2f0793292..591bc7caf 100644 --- a/weed/server/raft_server.go +++ b/weed/server/raft_server.go @@ -55,7 +55,7 @@ func NewRaftServer(r *mux.Router, peers []string, httpAddr string, dataDir strin if oldPeers, changed := isPeersChanged(s.dataDir, httpAddr, s.peers); changed { glog.V(0).Infof("Peers Change: %v => %v", oldPeers, s.peers) os.RemoveAll(path.Join(s.dataDir, "conf")) - // os.RemoveAll(path.Join(s.dataDir, "log")) + os.RemoveAll(path.Join(s.dataDir, "log")) os.RemoveAll(path.Join(s.dataDir, "snapshot")) } @@ -141,6 +141,10 @@ func isPeersChanged(dir string, self string, peers []string) (oldPeers []string, } oldPeers = append(oldPeers, self) + if len(peers) == 0 && len(oldPeers) <= 1 { + return oldPeers, false + } + sort.Strings(peers) sort.Strings(oldPeers)