showuon commented on code in PR #16211:
URL: https://github.com/apache/kafka/pull/16211#discussion_r1642365430


##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -132,8 +133,13 @@ public long timeUntilCheckQuorumExpires(long 
currentTimeMs) {
      */
     public void updateCheckQuorumForFollowingVoter(int id, long currentTimeMs) 
{
         updateFetchedVoters(id);
-        // The majority number of the voters excluding the leader. Ex: 3 
voters, the value will be 1
-        int majority = voterStates.size() / 2;
+        // The majority number of the voters. Ex: 2 for 3 voters, 3 for 4 
voters... etc.
+        int majority = (int) Math.ceil((double) (voterStates.size() + 1) / 2);
+        // Check if the leader is removed from the voter set
+        if (voterStates.containsKey(localId)) {
+            majority = majority - 1;

Review Comment:
   Looks good to me. Thanks.



##########
raft/src/main/java/org/apache/kafka/raft/LeaderState.java:
##########
@@ -132,8 +133,13 @@ public long timeUntilCheckQuorumExpires(long 
currentTimeMs) {
      */
     public void updateCheckQuorumForFollowingVoter(int id, long currentTimeMs) 
{
         updateFetchedVoters(id);
-        // The majority number of the voters excluding the leader. Ex: 3 
voters, the value will be 1
-        int majority = voterStates.size() / 2;
+        // The majority number of the voters. Ex: 2 for 3 voters, 3 for 4 
voters... etc.
+        int majority = (int) Math.ceil((double) (voterStates.size() + 1) / 2);

Review Comment:
   That works, too. Updated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to