kevin-wu24 commented on code in PR #21025:
URL: https://github.com/apache/kafka/pull/21025#discussion_r2578058942


##########
raft/src/main/java/org/apache/kafka/raft/internals/AddVoterHandler.java:
##########
@@ -156,6 +156,23 @@ public CompletableFuture<AddRaftVoterResponseData> 
handleAddVoterRequest(
             );
         }
 
+
+        if (!ackWhenCommitted && partitionState.hasSeenReplicaKey(voterKey)) {
+            // ackWhenCommitted is used to distinguish the request from admin
+            // or broker. If it comes from broker and had been in cluster, we 
should
+            // reject it.
+            return CompletableFuture.completedFuture(
+                RaftUtil.addVoterResponse(
+                    Errors.INVALID_VOTER_KEY,

Review Comment:
   Return `Errors.DUPLICATE_VOTER`.



##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -2339,6 +2341,9 @@ private boolean handleAddVoterResponse(
             error == Errors.DUPLICATE_VOTER) {
             
quorum.followerStateOrThrow().resetUpdateVoterSetPeriod(currentTimeMs);
             return true;
+        } else if (error == Errors.INVALID_VOTER_KEY) {
+            hasJoined = true;
+            return true;

Review Comment:
   We want to use `Errors.DUPLICATE_VOTER` not `Errors.INVALID_VOTER_KEY`, 
since the former error code means the requested node is already a part of the 
voter set. 
   
   Whenever the requesting node receives a `DUPLICATE_VOTER` response, it knows 
for sure it can turn off auto-join code.



##########
raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java:
##########
@@ -2667,8 +2672,6 @@ private Optional<Boolean> maybeHandleCommonResponse(
         } else if (error == Errors.BROKER_NOT_AVAILABLE) {
             return Optional.of(false);
         } else if (error == Errors.INVALID_VOTER_KEY) {
-            // The voter key in the request for VOTE and BEGIN_QUORUM_EPOCH 
doesn't match the

Review Comment:
   Please revert this



-- 
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