gengliangwang commented on a change in pull request #28859:
URL: https://github.com/apache/spark/pull/28859#discussion_r449339030



##########
File path: 
core/src/main/scala/org/apache/spark/deploy/history/HistoryServerDiskManager.scala
##########
@@ -75,14 +75,32 @@ private class HistoryServerDiskManager(
 
     // Go through the recorded store directories and remove any that may have 
been removed by
     // external code.
-    val orphans = listing.view(classOf[ApplicationStoreInfo]).asScala.filter { 
info =>
-      !new File(info.path).exists()
-    }.toSeq
+    val (existing, orphans) = listing
+      .view(classOf[ApplicationStoreInfo])
+      .asScala
+      .toSeq
+      .partition { info =>
+        new File(info.path).exists()
+      }
 
     orphans.foreach { info =>
       listing.delete(info.getClass(), info.path)
     }
 
+    // Reading level db would trigger table file compaction, then it may cause 
size of level db
+    // directory changed. When service restarts, "currentUsage" is calculated 
from real directory
+    // size. Update "ApplicationStoreInfo.size" to ensure "currentUsage" equals
+    // sum of "ApplicationStoreInfo.size".
+    val changedStoreInfo = existing.filter { info =>

Review comment:
       Nit: I think we can write this in one loop:
   ```
   existing.foreach { info =>
     val fileSize = sizeOf(new File(info.path)
     if (fileSize != info.size) {
       listing.write(info.copy(size = fileSize))
     }
   }
   ```




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to