Skip to content

Commit

Permalink
etcdserver: fix mayRemoveMember still return ErrUnhealthy even if the…
Browse files Browse the repository at this point in the history
…re are majority members alive.

It resolves: etcd-io#15710
The number of active members shouldn't minus 1 when the member to remove is dead.

Signed-off-by: zzzzwc <tiddar@foxmail.com>
  • Loading branch information
zzzzwc committed Apr 13, 2023
1 parent 22f3e50 commit bf096d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1551,9 +1551,14 @@ func (s *EtcdServer) mayRemoveMember(id types.ID) error {
}

// protect quorum if some members are down
m := s.cluster.VotingMembers()
active := numConnectedSince(s.r.transport, time.Now().Add(-HealthInterval), s.MemberId(), m)
if (active - 1) < 1+((len(m)-1)/2) {
members := s.cluster.VotingMembers()
active := 0
for _, m := range members {
if m.ID == s.MemberId() || isConnectedSince(s.r.transport, time.Now().Add(-HealthInterval), m.ID) && m.ID != id {
active++
}
}
if active < 1+((len(members)-1)/2) {
lg.Warn(
"rejecting member remove request; local member has not been connected to all peers, reconfigure breaks active quorum",
zap.String("local-member-id", s.MemberId().String()),
Expand Down

0 comments on commit bf096d7

Please sign in to comment.