jolshan commented on a change in pull request #10282: URL: https://github.com/apache/kafka/pull/10282#discussion_r597931453
########## File path: core/src/main/scala/kafka/server/RaftReplicaManager.scala ########## @@ -374,4 +375,31 @@ class RaftReplicaManager(config: KafkaConfig, metadataImage.partitions.topicPartition(partition.topic, partition.partitionId).getOrElse( throw new IllegalStateException(s"Partition has metadata changes but does not exist in the metadata cache: ${partition.topicPartition}")) } + + /** + * Checks if the topic ID received from the MetadataPartitionsBuilder is consistent with the topic ID in the log. + * If the log does not exist, logTopicIdOpt will be None. In this case, the ID is not inconsistent. + * + * @param receivedTopicIdOpt the topic ID received from the MetadataRecords if it exists + * @param logTopicIdOpt the topic ID in the log if the log exists + * @param topicPartition the topicPartition for the Partition being checked + * @throws InconsistentTopicIdException if the topic ids are not consistent + * @throws IllegalArgumentException if the MetadataPartitionsBuilder did not have a topic ID associated with the topic + */ + private def checkTopicId(receivedTopicIdOpt: Option[Uuid], logTopicIdOpt: Option[Uuid], topicPartition: TopicPartition): Unit = { + receivedTopicIdOpt match { + case Some(receivedTopicId) => + logTopicIdOpt.foreach(logTopicId => { + if (receivedTopicId != logTopicId) { + // not sure if we need both the logger and the error thrown + stateChangeLogger.error(s"Topic Id in memory: $logTopicId does not" + Review comment: Ah I think I've been going by calling it topic ID when referring to the concept and TopicId when referring to a specific variable. But I didn't follow either case here. I'll make it more consistent. -- 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