dengziming commented on a change in pull request #9622: URL: https://github.com/apache/kafka/pull/9622#discussion_r543331298
########## File path: core/src/main/scala/kafka/server/MetadataCache.scala ########## @@ -314,9 +315,16 @@ class MetadataCache(brokerId: Int) extends Logging { error(s"Listeners are not identical across brokers: $aliveNodes") } + val newTopicIds = updateMetadataRequest.topicStates().asScala + .map(topicState => (topicState.topicName(), topicState.topicId())) + .filter(_._2 != Uuid.ZERO_UUID).toMap + val topicIds = mutable.Map.empty[String, Uuid] + topicIds.addAll(metadataSnapshot.topicIds) + topicIds.addAll(newTopicIds) Review comment: Hi, @rajinisivaram ,Thank you for your reply. I find that when KafkaController deletes a topic it will send `updateMetadataRequest` with all the partitions in it, and set `state.leader=-2` indicating the partition is deleted. And the `MetadataCache` will not remove the topic from cache but just keep the `UpdateMetadataPartitionState` of the deleted topics, so I also keep the topicId when deleted. here I tried to delete a topic and then describe it. ➜ ~ kafka-topics.sh --delete --zookeeper localhost:2181 --topic old-version-topic Topic old-version-topic is marked for deletion. Note: This will have no impact if delete.topic.enable is not set to true. ➜ ~ kafka-topics.sh --describe --zookeeper localhost:2181 --topic old-version-topic Topic: old-version-topic TopicId: wRPl6VAlQeyE77bDxEESzg PartitionCount: 1 ReplicationFactor: 1 Configs: MarkedForDeletion: true Topic: old-version-topic Partition: 0 Leader: 0 Replicas: 0 Isr: 0 MarkedForDeletion: true So the topicId of the deleted topic should also remain when deleted, when do you think we should delete the topicId from MetadataCache? suggestions are welcomed. ---------------------------------------------------------------- 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