Skip to content

Commit 609bf48

Browse files
committed
[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 df08673 commit 609bf48

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ import org.apache.spark.executor.ExecutorExitCode
2626
import org.apache.spark.network.netty.{PathResolver, ShuffleSender}
2727
import org.apache.spark.util.Utils
2828

29-
import scala.collection.mutable.ArrayBuffer
30-
3129
/**
3230
* Creates and maintains the logical mapping between logical blocks and physical on-disk
3331
* locations. By default, one block is mapped to one file with a name given by its BlockId.
@@ -47,7 +45,7 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
4745
* having really large inodes at the top level. */
4846
private val localDirs: Array[File] = createLocalDirs()
4947
if (localDirs.isEmpty) {
50-
logError("Failed to create any local dir")
48+
logError("Failed to create any local dir.")
5149
System.exit(ExecutorExitCode.DISK_STORE_FAILED_TO_CREATE_DIR)
5250
}
5351
private val subDirs = Array.fill(localDirs.length)(new Array[File](subDirsPerLocalDir))
@@ -121,9 +119,8 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
121119

122120
private def createLocalDirs(): Array[File] = {
123121
logDebug(s"Creating local directories at root dirs '$rootDirs'")
124-
val localDirsResult = ArrayBuffer[File]()
125122
val dateFormat = new SimpleDateFormat("yyyyMMddHHmmss")
126-
rootDirs.split(",").foreach { rootDir =>
123+
rootDirs.split(",").flatMap { rootDir =>
127124
var foundLocalDir = false
128125
var localDir: File = null
129126
var localDirId: String = null
@@ -143,13 +140,14 @@ private[spark] class DiskBlockManager(shuffleManager: ShuffleBlockManager, rootD
143140
}
144141
}
145142
if (!foundLocalDir) {
146-
logError(s"Failed $MAX_DIR_CREATION_ATTEMPTS attempts to create local dir in $rootDir")
143+
logError(s"Failed $MAX_DIR_CREATION_ATTEMPTS attempts to create local dir in $rootDir." +
144+
" Ignoring this directory.")
145+
None
147146
} else {
148147
logInfo(s"Created local directory at $localDir")
149-
localDirsResult += localDir
148+
Some(localDir)
150149
}
151150
}
152-
localDirsResult.toArray
153151
}
154152

155153
private def addShutdownHook() {

0 commit comments

Comments
 (0)