junrao commented on code in PR #12029: URL: https://github.com/apache/kafka/pull/12029#discussion_r852311641
########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -306,24 +306,27 @@ class UnifiedLog(@volatile var logStartOffset: Long, * - Otherwise set _topicId to None */ def initializeTopicId(): Unit = { - if (partitionMetadataFile.exists()) { + val thePartitionMetadataFile = partitionMetadataFile.getOrElse( Review Comment: thePartitionMetadataFile => partMetadataFile ? ########## core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala: ########## @@ -2703,6 +2711,26 @@ class ReplicaManagerTest { assertEquals(HostedPartition.None, replicaManager.getPartition(tp0)) assertFalse(readRecoveryPointCheckpoint().contains(tp0)) assertFalse(readLogStartOffsetCheckpoint().contains(tp0)) + + // verify that there is log to be deleted + val logsToBeDeleted = replicaManager.logManager.logsToBeDeleted Review Comment: Thanks for the explanation. Sounds good. ########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -573,9 +576,14 @@ class UnifiedLog(@volatile var logStartOffset: Long, case None => if (keepPartitionMetadataFile) { _topicId = Some(topicId) - if (!partitionMetadataFile.exists()) { - partitionMetadataFile.record(topicId) - scheduler.schedule("flush-metadata-file", maybeFlushMetadataFile) + partitionMetadataFile match { + case Some(partitionMetadataFile) => Review Comment: partitionMetadataFile => partMetadataFile ? -- 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