Skip to content

Commit

Permalink
[SPARK-23608][CORE][WEBUI] Add synchronization in SHS between attachS…
Browse files Browse the repository at this point in the history
…parkUI 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 <yezhou@linkedin.com>

Closes #20744 from zhouyejoe/SPARK-23608.

(cherry picked from commit 3675af7)
Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
  • Loading branch information
zhouyejoe authored and Marcelo Vanzin committed Mar 16, 2018
1 parent 52a52d5 commit 99f5c0b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 99f5c0b

Please sign in to comment.