hachikuji commented on a change in pull request #10252: URL: https://github.com/apache/kafka/pull/10252#discussion_r586709124
########## File path: core/src/main/scala/kafka/server/metadata/MetadataPartitions.scala ########## @@ -124,8 +125,30 @@ class MetadataPartitionsBuilder(val brokerId: Int, def removeTopicById(id: Uuid): Iterable[MetadataPartition] = { Option(newIdMap.remove(id)) match { - case None => throw new RuntimeException(s"Unable to locate topic with ID $id") - case Some(name) => newNameMap.remove(name).values().asScala + case None => + throw new RuntimeException(s"Unable to locate topic with ID $id") + + case Some(name) => + newReverseIdMap.remove(name) + + val prevPartitionMap = newNameMap.remove(name) + changed.remove(prevPartitionMap) + + val removedPartitions = prevPartitionMap.values + if (prevPartitions.topicIdToName(id).isDefined) { + removedPartitions.forEach { partition => + if (partition.isReplicaFor(brokerId)) { Review comment: I couldn't come up with a nice way to do this without avoiding unnecessary/redundant checks. I did pull out a little helper for checking if the previous image has a particular topic id. ---------------------------------------------------------------- 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