hachikuji commented on code in PR #13107: URL: https://github.com/apache/kafka/pull/13107#discussion_r1068783227
########## 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: Basically what I wanted is to have -2 sent as the leader epoch whenever the delete flag was enabled in the `StopReplica` request. That seemed simpler than trying to pinpoint specific cases, such as reassignment cancellation. -- 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