Skip to content

Commit

Permalink
do not update RaftCluster.members and RaftCluster.removed if the v3st…
Browse files Browse the repository at this point in the history
…ore is ahead of the current replayed WAL entry index

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Sep 27, 2023
1 parent fa59d98 commit 50f7eea
Showing 1 changed file with 43 additions and 28 deletions.
71 changes: 43 additions & 28 deletions server/etcdserver/api/membership/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,19 +395,27 @@ func (c *RaftCluster) AddMember(m *Member, shouldApplyV3 ShouldApplyV3) {
}
if c.be != nil && shouldApplyV3 {
c.be.MustSaveMemberToBackend(m)
}

c.members[m.ID] = m
c.updateMembershipMetric(m.ID, true)
c.members[m.ID] = m
c.updateMembershipMetric(m.ID, true)

c.lg.Info(
"added member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("added-peer-id", m.ID.String()),
zap.Strings("added-peer-peer-urls", m.PeerURLs),
zap.Bool("added-peer-is-learner", m.IsLearner),
)
c.lg.Info(
"added member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("added-peer-id", m.ID.String()),
zap.Strings("added-peer-peer-urls", m.PeerURLs),
zap.Bool("added-peer-is-learner", m.IsLearner),
)
} else {
c.lg.Info(
"ignore already added member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("added-peer-id", m.ID.String()),
zap.Strings("added-peer-peer-urls", m.PeerURLs),
zap.Bool("added-peer-is-learner", m.IsLearner),
}

Check failure on line 418 in server/etcdserver/api/membership/cluster.go

View workflow job for this annotation

GitHub Actions / test

expected operand, found '}'
}

// RemoveMember removes a member from the store.
Expand All @@ -420,25 +428,32 @@ func (c *RaftCluster) RemoveMember(id types.ID, shouldApplyV3 ShouldApplyV3) {
}

Check failure on line 428 in server/etcdserver/api/membership/cluster.go

View workflow job for this annotation

GitHub Actions / test

missing ',' before newline in argument list
if c.be != nil && shouldApplyV3 {

Check failure on line 429 in server/etcdserver/api/membership/cluster.go

View workflow job for this annotation

GitHub Actions / test

expected operand, found 'if'

Check failure on line 429 in server/etcdserver/api/membership/cluster.go

View workflow job for this annotation

GitHub Actions / test

missing ',' in argument list
c.be.MustDeleteMemberFromBackend(id)

Check failure on line 430 in server/etcdserver/api/membership/cluster.go

View workflow job for this annotation

GitHub Actions / test

missing ',' before newline in composite literal
}

m, ok := c.members[id]
delete(c.members, id)
c.removed[id] = true
c.updateMembershipMetric(id, false)

if ok {
c.lg.Info(
"removed member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("removed-remote-peer-id", id.String()),
zap.Strings("removed-remote-peer-urls", m.PeerURLs),
zap.Bool("removed-remote-peer-is-learner", m.IsLearner),
)
m, ok := c.members[id]
delete(c.members, id)
c.removed[id] = true
c.updateMembershipMetric(id, false)

if ok {
c.lg.Info(
"removed member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("removed-remote-peer-id", id.String()),
zap.Strings("removed-remote-peer-urls", m.PeerURLs),
zap.Bool("removed-remote-peer-is-learner", m.IsLearner),
)
} else {
c.lg.Warn(
"skipped removing already removed member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("removed-remote-peer-id", id.String()),
)
}
} else {
c.lg.Warn(
"skipped removing already removed member",
c.lg.Info(
"ignore already removed member",
zap.String("cluster-id", c.cid.String()),
zap.String("local-member-id", c.localID.String()),
zap.String("removed-remote-peer-id", id.String()),
Expand Down

0 comments on commit 50f7eea

Please sign in to comment.