Repository: spark
Updated Branches:
  refs/heads/branch-2.3 52a52d5d2 -> 99f5c0bc7


[SPARK-23608][CORE][WEBUI] Add synchronization in SHS between attachSparkUI and 
detachSparkUI functions to avoid concurrent modification issue to Jetty Handlers

Jetty handlers are dynamically attached/detached while SHS is running. But the 
attach and detach operations might be taking place at the same time due to the 
async in load/clear in Guava Cache.

## What changes were proposed in this pull request?
Add synchronization between attachSparkUI and detachSparkUI in SHS.

## How was this patch tested?
With this patch, the jetty handlers missing issue never happens again in our 
production cluster SHS.

Author: Ye Zhou <[email protected]>

Closes #20744 from zhouyejoe/SPARK-23608.

(cherry picked from commit 3675af7247e841e9a689666dc20891ba55c612b3)
Signed-off-by: Marcelo Vanzin <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/99f5c0bc
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/99f5c0bc
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/99f5c0bc

Branch: refs/heads/branch-2.3
Commit: 99f5c0bc7a6c77917b4ccd498724b8ccc0c21473
Parents: 52a52d5
Author: Ye Zhou <[email protected]>
Authored: Thu Mar 15 17:15:53 2018 -0700
Committer: Marcelo Vanzin <[email protected]>
Committed: Thu Mar 15 17:16:10 2018 -0700

----------------------------------------------------------------------
 .../org/apache/spark/deploy/history/HistoryServer.scala   | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/99f5c0bc/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala
----------------------------------------------------------------------
diff --git 
a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala 
b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala
index 0ec4afa..611fa56 100644
--- a/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala
+++ b/core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala
@@ -150,14 +150,18 @@ class HistoryServer(
       ui: SparkUI,
       completed: Boolean) {
     assert(serverInfo.isDefined, "HistoryServer must be bound before attaching 
SparkUIs")
-    ui.getHandlers.foreach(attachHandler)
-    addFilters(ui.getHandlers, conf)
+    handlers.synchronized {
+      ui.getHandlers.foreach(attachHandler)
+      addFilters(ui.getHandlers, conf)
+    }
   }
 
   /** Detach a reconstructed UI from this server. Only valid after bind(). */
   override def detachSparkUI(appId: String, attemptId: Option[String], ui: 
SparkUI): Unit = {
     assert(serverInfo.isDefined, "HistoryServer must be bound before detaching 
SparkUIs")
-    ui.getHandlers.foreach(detachHandler)
+    handlers.synchronized {
+      ui.getHandlers.foreach(detachHandler)
+    }
     provider.onUIDetached(appId, attemptId, ui)
   }
 


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

Reply via email to