Skip to content

Commit ef0ebdd

Browse files
ConeyLiucloud-fan
authored andcommitted
[SPARK-20250][CORE] Improper OOM error when a task been killed while spilling data
Currently, when a task is calling spill() but it receives a killing request from driver (e.g., speculative task), the `TaskMemoryManager` will throw an `OOM` exception. And we don't catch `Fatal` exception when a error caused by `Thread.interrupt`. So for `ClosedByInterruptException`, we should throw `RuntimeException` instead of `OutOfMemoryError`. https://issues.apache.org/jira/browse/SPARK-20250?jql=project%20%3D%20SPARK Existing unit tests. Author: Xianyang Liu <[email protected]> Closes #18090 from ConeyLiu/SPARK-20250. (cherry picked from commit 731462a) Signed-off-by: Wenchen Fan <[email protected]>
1 parent 79fbfbb commit ef0ebdd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/src/main/java/org/apache/spark/memory/TaskMemoryManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import javax.annotation.concurrent.GuardedBy;
2121
import java.io.IOException;
22+
import java.nio.channels.ClosedByInterruptException;
2223
import java.util.Arrays;
2324
import java.util.BitSet;
2425
import java.util.HashSet;
@@ -156,6 +157,10 @@ public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
156157
break;
157158
}
158159
}
160+
} catch (ClosedByInterruptException e) {
161+
// This called by user to kill a task (e.g: speculative task).
162+
logger.error("error while calling spill() on " + c, e);
163+
throw new RuntimeException(e.getMessage());
159164
} catch (IOException e) {
160165
logger.error("error while calling spill() on " + c, e);
161166
throw new OutOfMemoryError("error while calling spill() on " + c + " : "
@@ -174,6 +179,10 @@ public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
174179
Utils.bytesToString(released), consumer);
175180
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
176181
}
182+
} catch (ClosedByInterruptException e) {
183+
// This called by user to kill a task (e.g: speculative task).
184+
logger.error("error while calling spill() on " + consumer, e);
185+
throw new RuntimeException(e.getMessage());
177186
} catch (IOException e) {
178187
logger.error("error while calling spill() on " + consumer, e);
179188
throw new OutOfMemoryError("error while calling spill() on " + consumer + " : "

0 commit comments

Comments
 (0)