Skip to content

Commit 1a45ff5

Browse files
committed
throw RuntimeException against OutOfMemoryError when a task been killed while spilling data
1 parent bc66a77 commit 1a45ff5

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.ArrayList;
2425
import java.util.BitSet;
@@ -184,6 +185,10 @@ public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
184185
break;
185186
}
186187
}
188+
} catch (ClosedByInterruptException e) {
189+
// This called by user to kill a task (e.g: speculative task).
190+
logger.error("error while calling spill() on " + c, e);
191+
throw new RuntimeException(e.getMessage());
187192
} catch (IOException e) {
188193
logger.error("error while calling spill() on " + c, e);
189194
throw new OutOfMemoryError("error while calling spill() on " + c + " : "
@@ -201,6 +206,10 @@ public long acquireExecutionMemory(long required, MemoryConsumer consumer) {
201206
Utils.bytesToString(released), consumer);
202207
got += memoryManager.acquireExecutionMemory(required - got, taskAttemptId, mode);
203208
}
209+
} catch (ClosedByInterruptException e) {
210+
// This called by user to kill a task (e.g: speculative task).
211+
logger.error("error while calling spill() on " + consumer, e);
212+
throw new RuntimeException(e.getMessage());
204213
} catch (IOException e) {
205214
logger.error("error while calling spill() on " + consumer, e);
206215
throw new OutOfMemoryError("error while calling spill() on " + consumer + " : "

0 commit comments

Comments
 (0)