diff options
author | zuotingbing <zuo.tingbing9@zte.com.cn> | 2017-01-08 09:29:01 +0000 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2017-01-08 09:29:01 +0000 |
commit | cd1d00adaff65e8adfebc2342dd422c53f98166b (patch) | |
tree | 860a3b47d5fae58478dd3f031337129d635979d4 /core | |
parent | 6b6b555a1e667a9f03dfe4a21e56c513a353a58d (diff) | |
download | spark-cd1d00adaff65e8adfebc2342dd422c53f98166b.tar.gz spark-cd1d00adaff65e8adfebc2342dd422c53f98166b.tar.bz2 spark-cd1d00adaff65e8adfebc2342dd422c53f98166b.zip |
[SPARK-19026] SPARK_LOCAL_DIRS(multiple directories on different disks) cannot be deleted
JIRA Issue: https://issues.apache.org/jira/browse/SPARK-19026
SPARK_LOCAL_DIRS (Standalone) can be a comma-separated list of multiple directories on different disks, e.g. SPARK_LOCAL_DIRS=/dir1,/dir2,/dir3, if there is a IOExecption when create sub directory on dir3 , the sub directory which have been created successfully on dir1 and dir2 cannot be deleted anymore when the application finishes.
So we should catch the IOExecption at Utils.createDirectory , otherwise the variable "appDirectories(appId)" which the function maybeCleanupApplication calls will not be set then dir1 and dir2 will not be cleaned up .
Author: zuotingbing <zuo.tingbing9@zte.com.cn>
Closes #16439 from zuotingbing/master.
Diffstat (limited to 'core')
-rwxr-xr-x | core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala b/core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala index f963a46060..e48817ebba 100755 --- a/core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala +++ b/core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala @@ -445,12 +445,25 @@ private[deploy] class Worker( // Create local dirs for the executor. These are passed to the executor via the // SPARK_EXECUTOR_DIRS environment variable, and deleted by the Worker when the // application finishes. - val appLocalDirs = appDirectories.getOrElse(appId, - Utils.getOrCreateLocalRootDirs(conf).map { dir => - val appDir = Utils.createDirectory(dir, namePrefix = "executor") - Utils.chmod700(appDir) - appDir.getAbsolutePath() - }.toSeq) + val appLocalDirs = appDirectories.getOrElse(appId, { + val localRootDirs = Utils.getOrCreateLocalRootDirs(conf) + val dirs = localRootDirs.flatMap { dir => + try { + val appDir = Utils.createDirectory(dir, namePrefix = "executor") + Utils.chmod700(appDir) + Some(appDir.getAbsolutePath()) + } catch { + case e: IOException => + logWarning(s"${e.getMessage}. Ignoring this directory.") + None + } + }.toSeq + if (dirs.isEmpty) { + throw new IOException("No subfolder can be created in " + + s"${localRootDirs.mkString(",")}.") + } + dirs + }) appDirectories(appId) = appLocalDirs val manager = new ExecutorRunner( appId, |