Skip to content

Commit 5dd8fde

Browse files
zhouyejoemstewart141
authored andcommitted
[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 apache#20744 from zhouyejoe/SPARK-23608.
1 parent e1343b8 commit 5dd8fde

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,18 @@ class HistoryServer(
150150
ui: SparkUI,
151151
completed: Boolean) {
152152
assert(serverInfo.isDefined, "HistoryServer must be bound before attaching SparkUIs")
153-
ui.getHandlers.foreach(attachHandler)
154-
addFilters(ui.getHandlers, conf)
153+
handlers.synchronized {
154+
ui.getHandlers.foreach(attachHandler)
155+
addFilters(ui.getHandlers, conf)
156+
}
155157
}
156158

157159
/** Detach a reconstructed UI from this server. Only valid after bind(). */
158160
override def detachSparkUI(appId: String, attemptId: Option[String], ui: SparkUI): Unit = {
159161
assert(serverInfo.isDefined, "HistoryServer must be bound before detaching SparkUIs")
160-
ui.getHandlers.foreach(detachHandler)
162+
handlers.synchronized {
163+
ui.getHandlers.foreach(detachHandler)
164+
}
161165
provider.onUIDetached(appId, attemptId, ui)
162166
}
163167

0 commit comments

Comments
 (0)