gaurav-narula commented on code in PR #15136:
URL: https://github.com/apache/kafka/pull/15136#discussion_r1570959086


##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -1189,49 +1217,62 @@ class LogManager(logDirs: Seq[File],
       val sourceLog = currentLogs.get(topicPartition)
       val destLog = futureLogs.get(topicPartition)
 
-      info(s"Attempting to replace current log $sourceLog with $destLog for 
$topicPartition")
       if (sourceLog == null)
         throw new KafkaStorageException(s"The current replica for 
$topicPartition is offline")
       if (destLog == null)
         throw new KafkaStorageException(s"The future replica for 
$topicPartition is offline")
 
-      destLog.renameDir(UnifiedLog.logDirName(topicPartition), 
shouldReinitialize = true)
-      // the metrics tags still contain "future", so we have to remove it.
-      // we will add metrics back after sourceLog remove the metrics
-      destLog.removeLogMetrics()
-      destLog.updateHighWatermark(sourceLog.highWatermark)
+      info(s"Attempting to replace current log $sourceLog with $destLog for 
$topicPartition")
+      replaceCurrentWithFutureLog(Option(sourceLog), destLog, 
updateHighWatermark = true)
+      info(s"The current replica is successfully replaced with the future 
replica for $topicPartition")
+    }
+  }
+
+  def replaceCurrentWithFutureLog(sourceLog: Option[UnifiedLog], destLog: 
UnifiedLog, updateHighWatermark: Boolean = false): Unit = {

Review Comment:
   I think that's not necessarily true. `findAbandonedFutureLogs` may find a 
`sourceLog` if the log directory is online but I don't think it's safe to 
update the high watermark even then because sourceLog may be ahead of futureLog.



-- 
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

Reply via email to