-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPARK-3811 [CORE] More robust / standard Utils.deleteRecursively, Utils.createTempDir #2670
Conversation
…eption occurs; use one shutdown hook instead of one per method call to delete temp dirs
QA tests have started for PR 2670 at commit
|
QA tests have finished for PR 2670 at commit
|
Test PASSed. |
So, I've never been a fan of
And sure enough, after you run it, |
@@ -251,15 +265,8 @@ private[spark] object Utils extends Logging { | |||
} catch { case e: IOException => ; } | |||
} | |||
|
|||
dir.deleteOnExit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my top-level comment on this not really working for directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's almost just like insurance. I believe it works if the dir is empty, and under some circumstances it will delete stuff in the right order. I have no problem removing it on the grounds that it doesn't hurt, maybe helps, but, this is sort of meaningless because the code should actually delete things correctly already.
LGTM, just a few minor things. |
QA tests have started for PR 2670 at commit
|
QA tests have finished for PR 2670 at commit
|
Test PASSed. |
Can one of the admins verify this patch? |
Thanks @srowen. Merging to master. |
I noticed a few issues with how temp directories are created and deleted:
Minor
Files.createTempDir()
plusFile.deleteOnExit()
is used in many tests to make a temp dir, butUtils.createTempDir()
seems to be the standard Spark mechanismFile.deleteOnExit()
could be pushed intoUtils.createTempDir()
as well, along with this replacementUtils
in SPARK-3794; fixed hereBit Less Minor
Utils.deleteRecursively()
fails immediately if anyIOException
occurs, instead of trying to delete any remaining files and subdirectories. I've observed this leave temp dirs around. I suggest changing it to continue in the face of an exception and throw one of the possibly several exceptions that occur at the end.Utils.createTempDir()
will add a JVM shutdown hook every time the method is called. Even if the subdir is the parent of another parent dir, since this check is inside the hook. HoweverUtils
manages a set of all dirs to delete on shutdown already, calledshutdownDeletePaths
. A single hook can be registered to delete all of these on exit. This is how Tachyon temp paths are cleaned up inTachyonBlockManager
.I noticed a few other things that might be changed but wanted to ask first:
File
, not justString
paths?Utils
manages the set ofTachyonFile
that have been registered for deletion, but the shutdown hook is managed inTachyonBlockManager
. Should this logic not live together, and not inUtils
? it's more specific to Tachyon, and looks a slight bit odd to import in such a generic place.