Skip to content

RATIS-2008. Follower should recognize candidate if the candidate is the same peer as the current valid leader #1024

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

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

ivandika3
Copy link
Contributor

@ivandika3 ivandika3 commented Jan 22, 2024

What changes were proposed in this pull request?

During pre-vote, some follower reject the PRE_VOTE request from a candidate although the candidate has the same peer ID as the current leader.

2024-01-18 13:44:50,123 [grpc-default-executor-100] INFO org.apache.ratis.server.impl.VoteContext: e46cc30b-13ca-4778-b856-e84b0677493d@group-059247EC8137-FOLLOWER: reject PRE_VOTE from c7e3fa47-df62-4883-8d6e-50c3b6a9b94c: this server is a follower and still has a valid leader c7e3fa47-df62-4883-8d6e-50c3b6a9b94c

It might be a good idea to add another check so that if the candidate has the same peer ID as the follower's current recognized leader, we approve the PRE_VOTE request.

Note: The optimization might be marginal since leader is only valid after min.rpc.timeout (150ms). Afterwards, the follower should recognize the candidate.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2008

How was this patch tested?

Existing tests.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ivandika3 , this is a good idea!

  • We may combine the if-conditions.
  • Let's update the rejection message.
@@ -102,8 +102,10 @@ class VoteContext {
     if (info.isFollower()) {
       final RaftPeerId leader = impl.getState().getLeaderId();
       if (leader != null
+          && !leader.equals(candidateId)
           && impl.getRole().getFollowerState().map(FollowerState::isCurrentLeaderValid).orElse(false)) {
-        return reject("this server is a follower and still has a valid leader " + leader);
+        return reject("this server is a follower and still has a valid leader " + leader
+            + " different than the candidate " + candidateId);
       }
     }

@ivandika3 ivandika3 marked this pull request as ready for review January 24, 2024 01:18
@ivandika3
Copy link
Contributor Author

@szetszwo Thank you for the review. I have updated it accordingly. PTAL.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 the change looks good.

@szetszwo szetszwo merged commit 79923c2 into apache:master Jan 24, 2024
@ivandika3
Copy link
Contributor Author

Thank you for the review and merge @szetszwo

SzyWilliam pushed a commit that referenced this pull request Mar 27, 2024
symious pushed a commit to symious/ratis that referenced this pull request Apr 5, 2024
@ivandika3 ivandika3 deleted the RATIS-2008 branch May 29, 2024 01:54
SzyWilliam pushed a commit to SzyWilliam/ratis that referenced this pull request Jun 12, 2024
szetszwo pushed a commit to szetszwo/ratis that referenced this pull request Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants