hachikuji commented on a change in pull request #9539:
URL: https://github.com/apache/kafka/pull/9539#discussion_r516215666
##########
File path: raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java
##########
@@ -317,6 +317,9 @@ private void appendLeaderChangeMessage(LeaderState state,
long currentTimeMs) {
.map(follower -> new Voter().setVoterId(follower))
.collect(Collectors.toList());
+ // Adding the leader to the voters as the protocol ensures that leader
always votes for itself.
+ voters.add(new Voter().setVoterId(state.election().leaderId()));
Review comment:
I think the original KIP stated that the LeaderChange message would
encode the set of voters that had voted for the leader. We thought this might
be useful for debugging. Later on, we had a change of heart and decided it
would just be the set of voters. Now I'm thinking it might be useful to have
both. The log will always remember who the voters were at the time of the
election and which voters had granted the leader's candidacy, which could be
helpful in case of misconfigurations.
For the set of voters which voted for the current leader, I think what we
want is `CandidateState.grantingVoters`. However, by the time `onBecomeLeader`
is fired, we have already dropped the `CandidateState`. One option is to carry
`grantingVoters` over to `LeaderState`. We might also be able to pass it
through `onBecomeLeader`. This will be easier if we get rid of the call to
`onBecomeLeader` in `initialize()`. Following KAFKA-10527, it is not possible
to initialize as a leader, so we could raise an exception instead.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]