Skip to content

Commit 3bbeca6

Browse files
YanTangZhaiaarondav
authored andcommitted
[SPARK-2324] SparkContext should not exit directly when spark.local.dir is a list of multiple paths and one of them has error
The spark.local.dir is configured as a list of multiple paths as follows /data1/sparkenv/local,/data2/sparkenv/local. If the disk data2 of the driver node has error, the application will exit since DiskBlockManager exits directly at createLocalDirs. If the disk data2 of the worker node has error, the executor will exit either. DiskBlockManager should not exit directly at createLocalDirs if one of spark.local.dir has error. Since spark.local.dir has multiple paths, a problem should not affect the overall situation. I think DiskBlockManager could ignore the bad directory at createLocalDirs. Author: yantangzhai <[email protected]> Closes apache#1274 from YanTangZhai/SPARK-2324 and squashes the following commits: 609bf48 [yantangzhai] [SPARK-2324] SparkContext should not exit directly when spark.local.dir is a list of multiple paths and one of them has error df08673 [yantangzhai] [SPARK-2324] SparkContext should not exit directly when spark.local.dir is a list of multiple paths and one of them has error
1 parent bc7041a commit 3bbeca6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

core/src/main/scala/org/apache/spark/storage/DiskBlockManager.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
4444
* directory, create multiple subdirectories that we will hash files into, in order to avoid
4545
* having really large inodes at the top level. */
4646
private val localDirs: Array[File] = createLocalDirs()
47+
if (localDirs.isEmpty) {
48+
logError("Failed to create any local dir.")
49+
System.exit(ExecutorExitCode.DISK_STORE_FAILED_TO_CREATE_DIR)
50+
}
4751
private val subDirs = Array.fill(localDirs.length)(new Array[File](subDirsPerLocalDir))
4852
private var shuffleSender : ShuffleSender = null
4953

@@ -116,7 +120,7 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
116120
private def createLocalDirs(): Array[File] = {
117121
logDebug(s"Creating local directories at root dirs '$rootDirs'")
118122
val dateFormat = new SimpleDateFormat("yyyyMMddHHmmss")
119-
rootDirs.split(",").map { rootDir =>
123+
rootDirs.split(",").flatMap { rootDir =>
120124
var foundLocalDir = false
121125
var localDir: File = null
122126
var localDirId: String = null
@@ -136,11 +140,13 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
136140
}
137141
}
138142
if (!foundLocalDir) {
139-
logError(s"Failed $MAX_DIR_CREATION_ATTEMPTS attempts to create local dir in $rootDir")
140-
System.exit(ExecutorExitCode.DISK_STORE_FAILED_TO_CREATE_DIR)
143+
logError(s"Failed $MAX_DIR_CREATION_ATTEMPTS attempts to create local dir in $rootDir." +
144+
" Ignoring this directory.")
145+
None
146+
} else {
147+
logInfo(s"Created local directory at $localDir")
148+
Some(localDir)
141149
}
142-
logInfo(s"Created local directory at $localDir")
143-
localDir
144150
}
145151
}
146152

0 commit comments

Comments
 (0)