From c1450bf9fe59d304e94a7dee8051d8c02670edc4 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Fri, 25 Mar 2022 13:40:19 +0500 Subject: [PATCH 1/2] always clear previous log to avoid server is promotable https://github.com/chrislusf/seaweedfs/issues/2804 --- weed/server/raft_server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/weed/server/raft_server.go b/weed/server/raft_server.go index 91dd185c8..16afb5c7d 100644 --- a/weed/server/raft_server.go +++ b/weed/server/raft_server.go @@ -81,10 +81,11 @@ func NewRaftServer(option *RaftServerOption) (*RaftServer, error) { transporter := raft.NewGrpcTransporter(option.GrpcDialOption) glog.V(0).Infof("Starting RaftServer with %v", option.ServerAddr) + // always clear previous log to avoid server is promotable + os.RemoveAll(path.Join(s.dataDir, "log")) if !option.RaftResumeState { // always clear previous metadata os.RemoveAll(path.Join(s.dataDir, "conf")) - os.RemoveAll(path.Join(s.dataDir, "log")) os.RemoveAll(path.Join(s.dataDir, "snapshot")) } if err := os.MkdirAll(path.Join(s.dataDir, "snapshot"), 0600); err != nil { From ddd3945c26e6fe505697434d5d2d1cba909c8e29 Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Fri, 25 Mar 2022 15:09:38 +0500 Subject: [PATCH 2/2] fix remove deleted peers of raft server https://github.com/chrislusf/seaweedfs/issues/2804 --- weed/server/raft_server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/server/raft_server.go b/weed/server/raft_server.go index 16afb5c7d..f22b7c45d 100644 --- a/weed/server/raft_server.go +++ b/weed/server/raft_server.go @@ -119,17 +119,17 @@ func NewRaftServer(option *RaftServerOption) (*RaftServer, error) { exists := false var existingPeer pb.ServerAddress for _, peer := range s.peers { - if peer.ToGrpcAddress() == existsPeerName { + if peer.String() == existsPeerName { exists, existingPeer = true, peer break } } - if exists { + if !exists { if err := s.raftServer.RemovePeer(existsPeerName); err != nil { glog.V(0).Infoln(err) return nil, err } else { - glog.V(0).Infof("removing old peer %s", existingPeer) + glog.V(0).Infof("removing old peer: %s", existingPeer) } } }