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

etcdserver: return membership.ErrIDNotFound when the memberID not found #15095

Merged
merged 1 commit into from
Jan 16, 2023
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: 14 additions & 6 deletions server/etcdserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,10 @@ func (s *EtcdServer) mayPromoteMember(id types.ID) error {
// Note: it will return nil if member is not found in cluster or if member is not learner.
// These two conditions will be checked before toApply phase later.
func (s *EtcdServer) isLearnerReady(id uint64) error {
if err := s.waitAppliedIndex(); err != nil {
return err
}

rs := s.raftStatus()

// leader's raftStatus.Progress is not nil
Expand All @@ -1503,12 +1507,16 @@ func (s *EtcdServer) isLearnerReady(id uint64) error {
}
}

if isFound {
leaderMatch := rs.Progress[leaderID].Match
// the learner's Match not caught up with leader yet
if float64(learnerMatch) < float64(leaderMatch)*readyPercent {
return errors.ErrLearnerNotReady
}
// We should return an error in API directly, to avoid the request
// being unnecessarily delivered to raft.
if !isFound {
return membership.ErrIDNotFound
}

leaderMatch := rs.Progress[leaderID].Match
// the learner's Match not caught up with leader yet
if float64(learnerMatch) < float64(leaderMatch)*readyPercent {
return errors.ErrLearnerNotReady
}

return nil
Expand Down