Skip to content

Commit a59d76b

Browse files
author
wangfei
committed
Throw exception when memoryFracton is out of range
1 parent 7b899c2 commit a59d76b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ private[spark] object BlockManager extends Logging {
10461046
def getMaxMemory(conf: SparkConf): Long = {
10471047
val memoryFraction = conf.getDouble("spark.storage.memoryFraction", 0.6)
10481048
if (memoryFraction > 1 && memoryFraction <= 0) {
1049-
logWarning("spark.storage.memoryFraction should be between 0 and 1.")
1049+
throw new Exception("spark.storage.memoryFraction should be between 0 and 1.")
10501050
}
10511051
(Runtime.getRuntime.maxMemory * memoryFraction).toLong
10521052
}

core/src/main/scala/org/apache/spark/util/collection/ExternalAppendOnlyMap.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ class ExternalAppendOnlyMap[K, V, C](
7676
private val maxMemoryThreshold = {
7777
val memoryFraction = sparkConf.getDouble("spark.shuffle.memoryFraction", 0.3)
7878
val safetyFraction = sparkConf.getDouble("spark.shuffle.safetyFraction", 0.8)
79+
80+
if (memoryFraction > 1 && memoryFraction <= 0) {
81+
throw new Exception("spark.shuffle.memoryFraction should be between 0 and 1.")
82+
}
83+
84+
if (safetyFraction > 1 && safetyFraction <= 0) {
85+
throw new Exception("spark.shuffle.safetyFraction should be between 0 and 1.")
86+
}
87+
88+
7989
(Runtime.getRuntime.maxMemory * memoryFraction * safetyFraction).toLong
8090
}
8191

0 commit comments

Comments
 (0)