chia7712 commented on code in PR #15136:
URL: https://github.com/apache/kafka/pull/15136#discussion_r1570922398


##########
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:
   it seems we don't need `updateHighWatermark`, since we call 
`updateHighWatermark` only if `sourceLog` is defined.



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