This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 79923c2d7 RATIS-2008. Follower should recognize candidate if the
candidate is the same peer as the current valid leader (#1024)
79923c2d7 is described below
commit 79923c2d79c70dcf642c2c4bd24cfbf2501d0090
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;