jsancio commented on code in PR #16454:
URL: https://github.com/apache/kafka/pull/16454#discussion_r1663345822


##########
raft/src/main/java/org/apache/kafka/raft/CandidateState.java:
##########
@@ -86,10 +87,10 @@ protected CandidateState(
         this.backoffTimer = time.timer(0);
         this.log = logContext.logger(CandidateState.class);
 
-        for (Integer voterId : voters.voterIds()) {
-            voteStates.put(voterId, State.UNRECORDED);
+        for (ReplicaKey voter : voters.voterKeys()) {
+            voteStates.put(voter.id(), new VoterState(voter));
         }
-        voteStates.put(localId, State.GRANTED);
+        voteStates.get(localId).setState(State.GRANTED);

Review Comment:
   The invariant is that only voters can transition to `CandidateState` so that 
means that `voteState` will always contain the local id. I added this check to 
verify that: 
https://github.com/apache/kafka/blob/trunk/raft/src/main/java/org/apache/kafka/raft/CandidateState.java#L67-L76
   
   Having said that I was looking at some of the transitions and I see that we 
don't satisfy that invariant in all cases. I filed this jira for me to revisit 
this: [Fix the transition to 
CandidateState](https://issues.apache.org/jira/browse/KAFKA-17067). I probably 
should work on this Jira before we merge the AddRaftVoter RPC PR.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to