showuon commented on code in PR #15136:
URL: https://github.com/apache/kafka/pull/15136#discussion_r1562284319
##########
core/src/main/scala/kafka/log/LogManager.scala:
##########
@@ -1176,6 +1176,42 @@ class LogManager(logDirs: Seq[File],
}
}
+ def recoverAbandonedFutureLogs(brokerId: Int, newTopicsImage: TopicsImage):
Unit = {
+ val abandonedFutureLogs = findAbandonedFutureLogs(brokerId, newTopicsImage)
+ abandonedFutureLogs.foreach { case (futureLog, currentLog) =>
+ val tp = futureLog.topicPartition
+
+ futureLog.renameDir(UnifiedLog.logDirName(tp), shouldReinitialize = true)
+ futureLog.removeLogMetrics()
+ futureLogs.remove(tp)
+
+ currentLog.foreach { log =>
+ log.removeLogMetrics()
+ log.renameDir(UnifiedLog.logDeleteDirName(tp), shouldReinitialize =
false)
+ addLogToBeDeleted(log)
+ info(s"Old log for partition ${tp} is renamed to
${log.dir.getAbsolutePath} and is scheduled for deletion")
+ }
+
+ currentLogs.put(tp, futureLog)
+ futureLog.newMetrics()
+
+ info(s"Successfully renamed abandoned future log for $tp")
Review Comment:
I can see we basically do the similar things as what
`replaceCurrentWithFutureLog` did, why should we duplicate the codes here
again? Could we not be able to call `replaceCurrentWithFutureLog` with
additional parameters to indicate we want to skip some actions?
Like what we did now, we didn't close the `currentLog`, which should have
potential resource leak. Using the `replaceCurrentWithFutureLog` could avoid
this issue happening. WDYT?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]