Skip to content

Commit

Permalink
VINITUS-258: Backport SPARK-39083 (apache#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvn authored and GitHub Enterprise committed May 10, 2022
1 parent 4158bbc commit de454c0
Showing 1 changed file with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -629,37 +629,38 @@ 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)
}

maybeUI.foreach { ui =>
ui.invalidate()
ui.ui.store.close()
var isStale = false
listing.synchronized {
val app = load(appId)
val (attempt, others) = app.attempts.partition(_.info.attemptId == attemptId)

assert(attempt.isEmpty || attempt.size == 1)
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 {
if (others.nonEmpty) {
val newAppInfo = new ApplicationInfoWrapper(app.info, others)
listing.write(newAppInfo)
} else {
listing.delete(classOf[ApplicationInfoWrapper], appId)
}
true
}

diskManager.foreach(_.release(appId, attemptId, delete = true))
true
}
}

if (isStale) {
if (others.nonEmpty) {
val newAppInfo = new ApplicationInfoWrapper(app.info, others)
listing.write(newAppInfo)
} else {
listing.delete(classOf[ApplicationInfoWrapper], appId)
val maybeUI = synchronized {
activeUIs.remove(appId -> attemptId)
}
maybeUI.foreach { ui =>
ui.invalidate()
ui.ui.store.close()
}
diskManager.foreach(_.release(appId, attemptId, delete = true))
}
} catch {
case _: NoSuchElementException =>
Expand Down

0 comments on commit de454c0

Please sign in to comment.