Skip to content

Commit 022e06d

Browse files
Sital Kediadavies
authored andcommitted
[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 #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. (cherry picked from commit 2e0c528) Signed-off-by: Davies Liu <davies.liu@gmail.com>
1 parent 1fcd17f commit 022e06d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

core/src/main/java/org/apache/spark/shuffle/sort/ShuffleExternalSorter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,18 @@ private void growPointerArrayIfNecessary() throws IOException {
320320
assert(inMemSorter != null);
321321
if (!inMemSorter.hasSpaceForAnotherRecord()) {
322322
long used = inMemSorter.getMemoryUsage();
323-
LongArray array = allocateArray(used / 8 * 2);
323+
LongArray array;
324+
try {
325+
// could trigger spilling
326+
array = allocateArray(used / 8 * 2);
327+
} catch (OutOfMemoryError e) {
328+
// should have trigger spilling
329+
if (!inMemSorter.hasSpaceForAnotherRecord()) {
330+
logger.error("Unable to grow the pointer array");
331+
throw e;
332+
}
333+
return;
334+
}
324335
// check if spilling is triggered or not
325336
if (inMemSorter.hasSpaceForAnotherRecord()) {
326337
freeArray(array);

core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,18 @@ private void growPointerArrayIfNecessary() throws IOException {
292292
assert(inMemSorter != null);
293293
if (!inMemSorter.hasSpaceForAnotherRecord()) {
294294
long used = inMemSorter.getMemoryUsage();
295-
LongArray array = allocateArray(used / 8 * 2);
295+
LongArray array;
296+
try {
297+
// could trigger spilling
298+
array = allocateArray(used / 8 * 2);
299+
} catch (OutOfMemoryError e) {
300+
// should have trigger spilling
301+
if (!inMemSorter.hasSpaceForAnotherRecord()) {
302+
logger.error("Unable to grow the pointer array");
303+
throw e;
304+
}
305+
return;
306+
}
296307
// check if spilling is triggered or not
297308
if (inMemSorter.hasSpaceForAnotherRecord()) {
298309
freeArray(array);

0 commit comments

Comments
 (0)