Commit 03eb318
[SPARK-52615][CORE] Replace File.mkdirs with Utils.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 configure `spark.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 in `Utils.createDirectory`
> // SPARK-35907: The check was required by File.mkdirs() because it could sporadically
> // fail silently. ...
```
25/06/27 19:12:17 WARN Client: Neither spark.yarn.jars nor spark.yarn.archive is set, falling back to uploading libraries under SPARK_HOME.
25/06/27 19:12:17 ERROR Utils: Failed to create dir in ./local. Ignoring this directory.
25/06/27 19:12:17 INFO Client: Deleted staging directory hdfs://<cluster>/user/<user>/.sparkStaging/application_1747844918192_28291290
Exception in thread "main" java.io.IOException: Failed to get a temp directory under [./local].
at org.apache.spark.util.Utils$.getLocalDir(Utils.scala:896)
at org.apache.spark.deploy.yarn.Client.prepareLocalResources(Client.scala:672)
at org.apache.spark.deploy.yarn.Client.createContainerLaunchContext(Client.scala:1005)
at org.apache.spark.deploy.yarn.Client.submitApplication(Client.scala:231)
at org.apache.spark.deploy.yarn.Client.run(Client.scala:1352)
at org.apache.spark.deploy.yarn.YarnClusterApplication.start(Client.scala:1800)
at org.apache.spark.deploy.SparkSubmit.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:1019)
at org.apache.spark.deploy.SparkSubmit.doRunMain$1(SparkSubmit.scala:192)
at org.apache.spark.deploy.SparkSubmit.submit(SparkSubmit.scala:215)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:91)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1107)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1116)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
```
So I replaced `File.mkdirs` with `Utils.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](https://bugs.openjdk.org/browse/JDK-4227544) "design bug: File.mkdir(), etc. don't provide reason for failure" get closed with "Won't Fix"
> It is too late to change this now. The new io framework will handle this situation better.
### 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.
Closes #51322 from pan3793/SPARK-52615.
Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: yangjie01 <yangjie01@baidu.com>1 parent 2bd93da commit 03eb318
File tree
40 files changed
+79
-65
lines changed- common
- network-shuffle/src/test/java/org/apache/spark/network/shuffle
- utils/src/test/scala/org/apache/spark/util
- connector
- avro/src/test/scala/org/apache/spark/sql/avro
- kafka-0-10/src/test/scala/org/apache/spark/streaming/kafka010
- core/src
- main/scala/org/apache/spark
- deploy
- worker
- rdd
- storage
- util
- test/scala/org/apache/spark
- benchmark
- deploy
- history
- worker
- scheduler
- storage
- resource-managers/yarn/src/test/scala/org/apache/spark/network/yarn
- sql
- connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/streaming
- core/src
- main/scala/org/apache/spark/sql/execution/streaming/state
- test/scala/org/apache/spark/sql
- execution
- datasources
- json
- orc
- parquet
- python
- sources
- streaming
- test
- hive-thriftserver/src
- main/java/org/apache/hive/service/cli/session
- test/scala/org/apache/spark/sql/hive/thriftserver/ui
- hive/src/test/scala/org/apache/spark/sql/hive
40 files changed
+79
-65
lines changedLines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | | - | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
| 157 | + | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
| 299 | + | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1899 | 1899 | | |
1900 | 1900 | | |
1901 | 1901 | | |
1902 | | - | |
| 1902 | + | |
1903 | 1903 | | |
1904 | 1904 | | |
1905 | 1905 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
94 | | - | |
| 95 | + | |
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
600 | 600 | | |
601 | 601 | | |
602 | 602 | | |
603 | | - | |
| 603 | + | |
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
458 | 458 | | |
459 | 459 | | |
460 | 460 | | |
461 | | - | |
| 461 | + | |
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
813 | | - | |
| 813 | + | |
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
| |||
0 commit comments