Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change member removal logic to remove members only once. #4254

Merged
merged 3 commits into from
Nov 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions worker/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (g *groupi) applyState(state *pb.MembershipState) {
if g.state != nil && g.state.Counter > state.Counter {
return
}
oldState := g.state
g.state = state

// Sometimes this can cause us to lose latest tablet info, but that shouldn't cause any issues.
Expand Down Expand Up @@ -324,11 +325,24 @@ func (g *groupi) applyState(state *pb.MembershipState) {
if g.Node != nil {
// Lets have this block before the one that adds the new members, else we may end up
// removing a freshly added node.
for _, member := range g.state.Removed {
if member.GroupId == g.Node.gid && g.Node.AmLeader() {

for _, member := range g.state.GetRemoved() {
if member.GetGroupId() == g.Node.gid && g.Node.AmLeader() {
go func() {
// Don't try to remove a member if it's already marked as removed in
// the membership state and is not a current peer of the node.
_, isPeer := g.Node.Peer(member.GetId())
// isPeer should only be true if the rmeoved node is not the same as this node.
isPeer = isPeer && member.GetId() != g.Node.RaftContext.Id

for _, oldMember := range oldState.GetRemoved() {
if oldMember.GetId() == member.GetId() && !isPeer {
return
}
}

if err := g.Node.ProposePeerRemoval(
context.Background(), member.Id); err != nil {
context.Background(), member.GetId()); err != nil {
glog.Errorf("Error while proposing node removal: %+v", err)
}
}()
Expand Down