You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/05/03 13:22:22 UTC

[GitHub] [spark] tanvn commented on a diff in pull request #36424: [SPARK-39083][CORE] : Fix race condition between update and clean app data

tanvn commented on code in PR #36424:
URL: https://github.com/apache/spark/pull/36424#discussion_r863766221


##########
core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala:
##########
@@ -630,41 +630,44 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
   }
 
   private def cleanAppData(appId: String, attemptId: Option[String], logPath: String): Unit = {
-    try {
-      val app = load(appId)
-      val (attempt, others) = app.attempts.partition(_.info.attemptId == attemptId)
-
-      assert(attempt.isEmpty || attempt.size == 1)
-      val isStale = attempt.headOption.exists { a =>
-        if (a.logPath != new Path(logPath).getName()) {
-          // If the log file name does not match, then probably the old log file was from an
-          // in progress application. Just return that the app should be left alone.
-          false
-        } else {
-          val maybeUI = synchronized {
-            activeUIs.remove(appId -> attemptId)
-          }
+    // SPARK-39083 prevent race condition between update and clean app data
+    listing.synchronized {
+      try {
+        val app = load(appId)
+        val (attempt, others) = app.attempts.partition(_.info.attemptId == attemptId)
+
+        assert(attempt.isEmpty || attempt.size == 1)
+        val isStale = attempt.headOption.exists { a =>
+          if (a.logPath != new Path(logPath).getName()) {
+            // If the log file name does not match, then probably the old log file was from an
+            // in progress application. Just return that the app should be left alone.
+            false
+          } else {
+            val maybeUI = synchronized {

Review Comment:
   @srowen @dongjoon-hyun 
   Thanks for the advice. Just fixed it. I think it will be a little bit slower but not too slow 🤔 
   



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org