dongjoon-hyun commented on code in PR #59709:
URL: https://github.com/apache/spark/pull/59709#discussion_r4351459476


##########
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:
   Thank you. I'd like to keep the deterministic name. A second failure for the 
same name only replaces the kept copy with a newer copy of the same entity. 
Renaming within the same directory fails mostly when the directory is not 
writable or the disk is full, and then `persist` fails as well. Even then, the 
worker is accepted on its next registration attempt through the 
`idToWorker.contains(id)` path in `handleRegisterWorker`, only without being 
persisted.



-- 
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]

Reply via email to