TaiJuWu commented on code in PR #20859:
URL: https://github.com/apache/kafka/pull/20859#discussion_r2567177319
##########
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:
Sorry, from my understanding, this code should like below but after this
change it always true for controller.
```
// Q: After this condition, hasJoin always true
if (nodeId.isPresent() && (hasJoined.isEmpty()) ||
partitionState.lastVoterSet().size() == 1
&&
partitionState.lastVoterSet().isVoter(ReplicaKey.of(nodeId.getAsInt(),
nodeDirectoryId)))
{
// if voter set is a singleton set contain only local ReplicaKey
// it is the standalone bootstrap node
hasJoined = Optional.of(true);
}
```
--
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]