lbradstreet commented on a change in pull request #10754: URL: https://github.com/apache/kafka/pull/10754#discussion_r651818541
########## File path: core/src/main/scala/kafka/controller/KafkaController.scala ########## @@ -1658,10 +1658,21 @@ class KafkaController(val config: KafkaConfig, } private def processTopicIds(topicIdAssignments: Set[TopicIdReplicaAssignment]): Unit = { - if (config.usesTopicId) { - val updated = zkClient.setTopicIds(topicIdAssignments.filter(_.topicId.isEmpty), controllerContext.epochZkVersion) - val allTopicIdAssignments = updated ++ topicIdAssignments.filter(_.topicId.isDefined) - allTopicIdAssignments.foreach(topicIdAssignment => controllerContext.addTopicId(topicIdAssignment.topic, topicIdAssignment.topicId.get)) + // Create topic IDs for topics missing them if we are using topic IDs + // Otherwise, maintain what we have in the topicZNode + val updated = if (config.usesTopicId) { + zkClient.setTopicIds(topicIdAssignments.filter(_.topicId.isEmpty), controllerContext.epochZkVersion) + } else { + Set[TopicIdReplicaAssignment]() + } + + // Add topic IDs to controller context + // If we don't have IBP 2.8, but are running 2.8 code, put any topic IDs from the ZNode in controller context + // This is to avoid losing topic IDs during operations like partition reassignments while the cluster is in a mixed state + (updated ++ topicIdAssignments).foreach{ topicIdAssignment => Review comment: nit: `foreach{` to `foreach {` -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org