This is an automated email from the ASF dual-hosted git repository. williamsong pushed a commit to branch snapshot-3 in repository https://gitbox.apache.org/repos/asf/ratis.git
commit f8f12d8908e1eabbee3f12f9e84c00c1132345b8 Author: Ivan Andika <[email protected]> AuthorDate: Thu Jan 25 01:14:49 2024 +0800 RATIS-2008. Follower should recognize candidate if the candidate is the same peer as the current valid leader (#1024) --- .../src/main/java/org/apache/ratis/server/impl/VoteContext.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/VoteContext.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/VoteContext.java index 6375d652c..3ba0c0e01 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/VoteContext.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/VoteContext.java @@ -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); } } return true;
