kevin-wu24 commented on code in PR #20859:
URL: https://github.com/apache/kafka/pull/20859#discussion_r2567200843
##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -501,6 +503,14 @@ public void initialize(
logger.info("Reading KRaft snapshot and log as part of the
initialization");
partitionState.updateState();
logger.info("Starting voters are {}", partitionState.lastVoterSet());
+ if (nodeId.isPresent()) {
+ // if the the VotersRecord with the highest offset contain the
node id of this node,
+ // mark it as already joined because it is already in the voter
set.
+ // Check using ReplicaKey (id + directoryId) to handle KIP-853
properly
+ hasJoined = partitionState.lastVoterSet().isVoter(
+ ReplicaKey.of(nodeId.getAsInt(), nodeDirectoryId)
+ );
+ }
Review Comment:
Alternatively, you can set `hasJoined = Optional.of(true)` when the leader
is elected and `hasJoined.isEmpty()`.
--
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]