You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/06/07 22:03:40 UTC

[GitHub] [kafka] ccding commented on a change in pull request #10763: KAFKA-12520: Ensure log loading does not truncate producer state unless required

ccding commented on a change in pull request #10763:
URL: https://github.com/apache/kafka/pull/10763#discussion_r646971381



##########
File path: core/src/main/scala/kafka/log/LogLoader.scala
##########
@@ -368,12 +368,50 @@ object LogLoader extends Logging {
     for (swapFile <- swapFiles) {
       val logFile = new File(CoreUtils.replaceSuffix(swapFile.getPath, Log.SwapFileSuffix, ""))
       val baseOffset = Log.offsetFromFile(logFile)
+      // Check whether swap index files exist: if not, the cleaned files must exist due to the
+      // existence of swap log file. Therefore, we rename the cleaned files to swap files and continue.
+      var recoverable = true
+      val swapOffsetIndexFile = Log.offsetIndexFile(swapFile.getParentFile, baseOffset, Log.SwapFileSuffix)

Review comment:
       Is it possible to write something like the following in Scala?
   
   ```scala
   Vector(Log.offsetIndexFile, Log.timeIndexFile, Log.transactionIndexFile).foreach{
       fn => {
           swapIndexFile = fn(swapFile.getParentFile, baseOffset, Log.SwapFileSuffix)
           if (!swapIndexFile.exists()) {
               // ...
           }
           // other things
       }
   }
   ```




-- 
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:
users@infra.apache.org