[SPARK-13958] Executor OOM due to unbounded growth of pointer array in…
## What changes were proposed in this pull request? This change fixes the executor OOM which was recently introduced in PR apache/spark#11095 (Please fill in changes proposed in this fix) ## How was this patch tested? Tested by running a spark job on the cluster. (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests) (If this patch involves UI changes, please attach a screenshot; otherwise, remove this) … Sorter Author: Sital Kedia <skedia@fb.com> Closes #11794 from sitalkedia/SPARK-13958.
This commit is contained in:
parent
3537782168
commit
2e0c5284fd
|
@ -320,7 +320,18 @@ final class ShuffleExternalSorter extends MemoryConsumer {
|
|||
assert(inMemSorter != null);
|
||||
if (!inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
long used = inMemSorter.getMemoryUsage();
|
||||
LongArray array = allocateArray(used / 8 * 2);
|
||||
LongArray array;
|
||||
try {
|
||||
// could trigger spilling
|
||||
array = allocateArray(used / 8 * 2);
|
||||
} catch (OutOfMemoryError e) {
|
||||
// should have trigger spilling
|
||||
if (!inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
logger.error("Unable to grow the pointer array");
|
||||
throw e;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// check if spilling is triggered or not
|
||||
if (inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
freeArray(array);
|
||||
|
|
|
@ -293,7 +293,18 @@ public final class UnsafeExternalSorter extends MemoryConsumer {
|
|||
assert(inMemSorter != null);
|
||||
if (!inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
long used = inMemSorter.getMemoryUsage();
|
||||
LongArray array = allocateArray(used / 8 * 2);
|
||||
LongArray array;
|
||||
try {
|
||||
// could trigger spilling
|
||||
array = allocateArray(used / 8 * 2);
|
||||
} catch (OutOfMemoryError e) {
|
||||
// should have trigger spilling
|
||||
if (!inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
logger.error("Unable to grow the pointer array");
|
||||
throw e;
|
||||
}
|
||||
return;
|
||||
}
|
||||
// check if spilling is triggered or not
|
||||
if (inMemSorter.hasSpaceForAnotherRecord()) {
|
||||
freeArray(array);
|
||||
|
|
Loading…
Reference in a new issue