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

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