sarutak commented on code in PR #59709:
URL: https://github.com/apache/spark/pull/59709#discussion_r4349492410
##########
core/src/main/scala/org/apache/spark/deploy/master/FileSystemPersistenceEngine.scala:
##########
@@ -63,24 +64,60 @@ private[master] class FileSystemPersistenceEngine(
override def read[T: ClassTag](prefix: String): Seq[T] = {
val files = new File(dir).listFiles().filter(_.getName.startsWith(prefix))
- files.map(deserializeFromFile[T]).toImmutableArraySeq
+ files.flatMap { file =>
+ try {
+ Some(deserializeFromFile[T](file))
+ } catch {
+ case NonFatal(e) =>
+ // Skip an unreadable file, e.g. one left truncated by a crash, so
that it cannot block
+ // recovery. Rename it, instead of deleting it, so that it is kept
for inspection but no
+ // longer matches the app_, driver_ or worker_ prefix.
+ val corrupted = new File(dir, "corrupted_" + file.getName)
+ logWarning(log"Exception while reading persisted file ${MDC(PATH,
file.getPath())}, " +
+ log"renaming it to ${MDC(NEW_PATH, corrupted.getPath())}", e)
+ if (!file.renameTo(corrupted)) {
Review Comment:
Nit: on POSIX, `File.renameTo` silently replaces an existing
`corrupted_<name>`, so a second failure for the same name loses the copy kept
for inspection. If the rename fails instead, the file keeps its original name,
and a later persist of the same name, e.g. a worker re-registering with the
same id, fails with `File already exists`. Both are unlikely, so feel free to
ignore them. If you want to cover them, a unique target name like
`corrupted_<name>_<timestamp>`, plus `NEW_PATH` in the rename-failure log,
would handle most of it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]