songnon commented on code in PR #13451: URL: https://github.com/apache/kafka/pull/13451#discussion_r1436294870
########## core/src/main/scala/kafka/controller/KafkaController.scala: ########## @@ -1894,10 +1894,16 @@ class KafkaController(val config: KafkaConfig, val currentAssignment = controllerContext.partitionFullReplicaAssignment(topicPartition) val newAssignment = currentAssignment.reassignTo(replicas) val areNewReplicasAlive = newAssignment.addingReplicas.toSet.subsetOf(controllerContext.liveBrokerIds) + val currentLeader = controllerContext.partitionLeadershipInfo(topicPartition).get.leaderAndIsr.leader + val unneededAddingReplicas = currentAssignment.replicas.diff(newAssignment.replicas) if (!areNewReplicasAlive) Some(new ApiError(Errors.INVALID_REPLICA_ASSIGNMENT, s"Replica assignment has brokers that are not alive. Replica list: " + s"${newAssignment.addingReplicas}, live broker list: ${controllerContext.liveBrokerIds}")) + else if (unneededAddingReplicas.contains(currentLeader)) Review Comment: If we start with replicase (0, 1) and resign it to (1, 2), the `unneededAddingReplicas` would be empty as `currentAssignment.replicas` is (0, 1) and `newAssignment.replicas` is (1, 2, 0) ``` Updating assignment of partition t-0 from ReplicaAssignment(replicas=0,1, addingReplicas=, removingReplicas=) to ReplicaAssignment(replicas=1,2,0, addingReplicas=2, removingReplicas=0) (kafka.controller.KafkaController:62) ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org