vincent81jiang commented on a change in pull request #11327:
URL: https://github.com/apache/kafka/pull/11327#discussion_r710352059



##########
File path: core/src/main/scala/kafka/log/LogCleanerManager.scala
##########
@@ -511,6 +514,28 @@ private[log] class LogCleanerManager(val logDirs: 
Seq[File],
       uncleanablePartitions.get(log.parentDir).exists(partitions => 
partitions.contains(topicPartition))
     }
   }
+
+  def maintainUncleanablePartitions(): Unit = {
+    // Remove deleted partitions from uncleanablePartitions
+    inLock(lock) {
+      // Remove non-existing logDir
+      // Note: we don't use retain or filterInPlace method in this function 
because retain in deprecated in
+      // scala 2.13 while filterInPlace is not available in scala 2.12.
+      uncleanablePartitions.filterNot {
+        case (logDir, _) => logDirs.map(_.getAbsolutePath).contains(logDir)
+      }.keys.foreach {
+        uncleanablePartitions.remove(_)
+      }
+
+      uncleanablePartitions.values.foreach {
+        // Remove deleted partitions
+        partitions => partitions.filterNot(logs.contains(_)).foreach {
+          partitions.remove(_)

Review comment:
       Good catch. I thought "partitions.filterNot(logs.contains(_))" will 
generate a temporary collection first and then "foreach" iterates over the 
temporary collection.   It's better to remove this implicit assumption.




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