aboutsummaryrefslogtreecommitdiff
path: root/yarn
diff options
context:
space:
mode:
authorCarson Wang <carson.wang@intel.com>2016-03-16 10:56:01 +0000
committerSean Owen <sowen@cloudera.com>2016-03-16 10:56:01 +0000
commit496d2a2b403ac83b390a90519217dd310b0013a4 (patch)
treeff4729a8eb7e8b12df8a14c1db7d605053281e75 /yarn
parent1d95fb6785dd77d879d3d60e15320f72ab185fd3 (diff)
downloadspark-496d2a2b403ac83b390a90519217dd310b0013a4.tar.gz
spark-496d2a2b403ac83b390a90519217dd310b0013a4.tar.bz2
spark-496d2a2b403ac83b390a90519217dd310b0013a4.zip
[SPARK-13889][YARN] Fix integer overflow when calculating the max number of executor failure
## What changes were proposed in this pull request? The max number of executor failure before failing the application is default to twice the maximum number of executors if dynamic allocation is enabled. The default value for "spark.dynamicAllocation.maxExecutors" is Int.MaxValue. So this causes an integer overflow and a wrong result. The calculated value of the default max number of executor failure is 3. This PR adds a check to avoid the overflow. ## How was this patch tested? It tests if the value is greater that Int.MaxValue / 2 to avoid the overflow when it multiplies 2. Author: Carson Wang <carson.wang@intel.com> Closes #11713 from carsonwang/IntOverflow.
Diffstat (limited to 'yarn')
-rw-r--r--yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala b/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
index cd179cf328..a06e677a04 100644
--- a/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
+++ b/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala
@@ -73,7 +73,10 @@ private[spark] class ApplicationMaster(
} else {
sparkConf.get(EXECUTOR_INSTANCES).getOrElse(0)
}
- val defaultMaxNumExecutorFailures = math.max(3, 2 * effectiveNumExecutors)
+ // By default, effectiveNumExecutors is Int.MaxValue if dynamic allocation is enabled. We need
+ // avoid the integer overflow here.
+ val defaultMaxNumExecutorFailures = math.max(3,
+ if (effectiveNumExecutors > Int.MaxValue / 2) Int.MaxValue else (2 * effectiveNumExecutors))
sparkConf.get(MAX_EXECUTOR_FAILURES).getOrElse(defaultMaxNumExecutorFailures)
}