Skip to content

Commit 94adfe1

Browse files
leave expired apps alone to be deleted
1 parent 9872a9d commit 94adfe1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,29 @@ private[history] class FsHistoryProvider(conf: SparkConf) extends ApplicationHis
278278

279279
val now = System.currentTimeMillis()
280280
val appsToRetain = new mutable.LinkedHashMap[String, FsApplicationHistoryInfo]()
281+
val appsToClean = new mutable.LinkedHashMap[String, FsApplicationHistoryInfo]()
281282

282283
// Scan all logs from the log directory.
283284
// Only completed applications older than the specified max age will be deleted.
284285
applications.values.foreach { info =>
285286
if (now - info.lastUpdated <= maxAge || !info.completed) {
286287
appsToRetain += (info.id -> info)
287288
} else {
288-
try {
289-
fs.delete(new Path(logDir + "/" + info.logPath), true)
290-
} catch {
291-
case t: IOException => logError(s"IOException in cleaning logs of ${info.logPath}", t)
292-
appsToRetain += (info.id -> info)
293-
}
289+
appsToClean += (info.id -> info)
294290
}
295291
}
296292

297293
applications = appsToRetain
294+
295+
appsToClean.values.foreach { info =>
296+
try {
297+
fs.delete(new Path(logDir + "/" + info.logPath), true)
298+
} catch {
299+
case t: IOException =>
300+
logError(s"IOException in cleaning logs of ${info.logPath}", t)
301+
applications += (info.id -> info)
302+
}
303+
}
298304
} catch {
299305
case t: Exception => logError("Exception in cleaning logs", t)
300306
}

0 commit comments

Comments
 (0)