hachikuji commented on code in PR #13107: URL: https://github.com/apache/kafka/pull/13107#discussion_r1072693482
########## core/src/main/scala/kafka/controller/ControllerChannelManager.scala: ########## @@ -436,17 +436,22 @@ abstract class AbstractControllerBrokerRequestBatch(config: KafkaConfig, def addStopReplicaRequestForBrokers(brokerIds: Seq[Int], topicPartition: TopicPartition, deletePartition: Boolean): Unit = { - // A sentinel (-2) is used as an epoch if the topic is queued for deletion. It overrides - // any existing epoch. - val leaderEpoch = metadataInstance.leaderEpoch(topicPartition) - brokerIds.filter(_ >= 0).foreach { brokerId => val result = stopReplicaRequestMap.getOrElseUpdate(brokerId, mutable.Map.empty) - val alreadyDelete = result.get(topicPartition).exists(_.deletePartition) + val updatedDeletePartition = deletePartition || result.get(topicPartition).exists(_.deletePartition) + + // A sentinel (-2) is used as an epoch if the replica is to be deleted. + // It overrides any existing epoch. + val leaderEpoch = if (updatedDeletePartition) { Review Comment: Yeah, `DeletePartition` is set whenever the replica should be deleted, which would be the case after cancellation for all adding replicas. It does not necessarily imply topic deletion. -- 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