-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-52615][CORE] Replace File.mkdirs with Utils.createDirectory #51322
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
base: master
Are you sure you want to change the base?
Conversation
* Create a directory given the abstract pathname | ||
* @return true, if the directory is successfully created; otherwise, return false. | ||
*/ | ||
public static boolean createDirectory(File dir) { |
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.
Is this created because public class JavaUtils
is better than private[spark] trait SparkFileUtils
?
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.
To ensure that we fix every instances and to prevent a future regression, could you a Scalastyle and Checkstyle rule to ban .mkdirs
pattern, @pan3793 ?
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.
+1, LGTM (except the above Scalastyle and Checkstyle rule comment).
+1 |
Thanks for your advice, I thought it, but I am afraid we can not do that because there are many places call |
@@ -54,7 +54,7 @@ public void create() throws IOException { | |||
localDirs[i] = JavaUtils.createDirectory(root, "spark").getAbsolutePath(); | |||
|
|||
for (int p = 0; p < subDirsPerLocalDir; p ++) { | |||
new File(localDirs[i], String.format("%02x", p)).mkdirs(); | |||
JavaUtils.createDirectory(new File(localDirs[i], String.format("%02x", p))); |
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.
@dongjoon-hyun I moved the createDirectory
to JavaUtils
because of this place, since it's a test code, I can simply use java.nio.Files.createDirectory
then we don't need to expose the method in JavaUtils
publicly, please let me know which one you prefer.
Note: there are many places in Spark codebase directly call java.nio.Files.createDirectory
|
What changes were proposed in this pull request?
We hit an issue that
File.mkdirs()
may occasionally fail with no error during the submission phase(we didn't configurespark.yarn.archive
in that cluster so each submission requires packaging and uploading spark client jars, which cosumes a lot of disk IO), which was also mentioned inUtils.createDirectory
So I replaced
File.mkdirs
withUtils.createDirectory
and deployed it into our internal cluster, no similar failures happens after then ... (not sure why, maybe the replaced NIO method is more robust?)Additional context:
JDK-4227544 "design bug: File.mkdir(), etc. don't provide reason for failure" get closed with "Won't Fix"
Why are the changes needed?
To achieve better error message reporting when creating a directory fails.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
I made such a change in internal Spark, and deployed it to a busy YARN cluster, the submit process has been stable so far.
Was this patch authored or co-authored using generative AI tooling?
No.