junrao commented on code in PR #12029: URL: https://github.com/apache/kafka/pull/12029#discussion_r848692773
########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -687,8 +687,10 @@ class UnifiedLog(@volatile var logStartOffset: Long, producerStateManager.updateParentDir(dir) // re-initialize leader epoch cache so that LeaderEpochCheckpointFile.checkpoint can correctly reference // the checkpoint file in renamed log directory - initializeLeaderEpochCache() - initializePartitionMetadata() + if (reinitialize) { Review Comment: Could we move the above comment inside the bracket? ########## core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala: ########## @@ -2615,7 +2615,7 @@ class ReplicaManagerTest { @Test def testStopReplicaWithDeletePartitionAndExistingPartitionAndNewerLeaderEpochAndIOException(): Unit = { - testStopReplicaWithExistingPartition(2, true, true, Errors.KAFKA_STORAGE_ERROR) + testStopReplicaWithExistingPartition(2, true, true, Errors.NONE) Review Comment: Could we add a comment on when this doesn't hit the storage error? ########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -687,8 +687,10 @@ class UnifiedLog(@volatile var logStartOffset: Long, producerStateManager.updateParentDir(dir) // re-initialize leader epoch cache so that LeaderEpochCheckpointFile.checkpoint can correctly reference // the checkpoint file in renamed log directory - initializeLeaderEpochCache() - initializePartitionMetadata() + if (reinitialize) { + initializeLeaderEpochCache() Review Comment: If we don't need to initialize, it's probably safer to set leaderEpochCache to None. This prevents a concurrent append from flushing the leader epoch cache on an invalid file, which could cause the broker to shut down. -- 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