viktorsomogyi commented on code in PR #13975: URL: https://github.com/apache/kafka/pull/13975#discussion_r1258116664
########## core/src/main/scala/kafka/server/metadata/KRaftMetadataCache.scala: ########## @@ -174,14 +174,25 @@ class KRaftMetadataCache(val brokerId: Int) extends MetadataCache with Logging w errorUnavailableEndpoints: Boolean = false, errorUnavailableListeners: Boolean = false): Seq[MetadataResponseTopic] = { val image = _currentImage - topics.toSeq.flatMap { topic => - getPartitionMetadata(image, topic, listenerName, errorUnavailableEndpoints, errorUnavailableListeners).map { partitionMetadata => + if (!isInitialized()) { + topics.toSeq.map(topic => Review Comment: I agree, however unfortunately the Metadata protocol doesn't implement top level errors ([link](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/MetadataResponse.json)) so I tried to go around this. It's also an alternative to return LEADER_NOT_AVAILABLE, although that's rather partition level and not topic level as I understand, but it has the advantage that Java clients don't require any changes to handle it as it's a `RetriableException`. Would that be better instead? If you think that is a bit sketchy too I can start a KIP for this to add top level errors to the Metadata API. -- 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