kowshik commented on a change in pull request #10478: URL: https://github.com/apache/kafka/pull/10478#discussion_r611450200
########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -2586,11 +1999,15 @@ object Log { logDirFailureChannel: LogDirFailureChannel, lastShutdownClean: Boolean = true, topicId: Option[Uuid], - keepPartitionMetadataFile: Boolean): Log = { + keepPartitionMetadataFile: Boolean = true): Log = { + // create the log directory if it doesn't exist + Files.createDirectories(dir.toPath) val topicPartition = Log.parseTopicPartitionName(dir) - val producerStateManager = new ProducerStateManager(topicPartition, dir, maxProducerIdExpirationMs) - new Log(dir, config, logStartOffset, recoveryPoint, scheduler, brokerTopicStats, time, maxProducerIdExpirationMs, - producerIdExpirationCheckIntervalMs, topicPartition, producerStateManager, logDirFailureChannel, lastShutdownClean, topicId, keepPartitionMetadataFile) + val logLoader = new LogLoader(dir, topicPartition, config, scheduler, time, logDirFailureChannel) Review comment: Great point. I tried this, but few problems I ran into were: 1. A test tries to intercept the recovery logic by overriding `def recoverLog` in `LogLoader`. Ex: `LogLoaderTest.testLogRecoveryIsCalledUponBrokerCrash`. 2. Some tests like to inject a custom `ProducerStateManager`, ex: `LogLoaderTest.testSkipTruncateAndReloadIfNewMessageFormatAndCleanShutdown`. 3. Some tests like to inject a custom `LogSegments`, ex: `LogLoaderTest. testProducerSnapshotsRecoveryAfterUncleanShutdownCurrentMessageFormat`. I'm working on solving these issues, and will post a PR update soon. -- 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