Reading Executor Logs
The Spark UI tells you an executor was lost and which tasks went down with it. It cannot tell you why the process stopped, because the reason was written to that executor's own stderr seconds before it exited. Each executor is a separate JVM that writes its log lines to a stderr file on its worker, and while it is alive the Executors tab links to that file in the Logs column.
After the executor exits and its container is cleaned up, that link goes dead. The file then lives wherever your cluster manager aggregates container logs, under the application ID and the executor's container. The event log behind the history server keeps metrics and plans but no executor stderr, so copy the logs you need before the cluster manager's retention deletes them.
First error versus loudest error
When an executor dies, every task that depended on it fails as well, and each failure writes its own lines. A reducer fetching shuffle blocks from the dead executor logs a FetchFailedException, retries, and logs again. Across a few hundred reducers that is thousands of lines, all of which read like a network fault. The cause is usually a single line, earlier, on a different machine.
| Time | Where | Line |
|---|---|---|
| 13:42:03 | executor 7 | WARN TaskMemoryManager: Failed to allocate a page (67108864 bytes), try again. |
| 13:42:05 | executor 7 | WARN TaskMemoryManager: Failed to allocate a page (67108864 bytes), try again. |
| 13:42:09 | executor 7 | ERROR Executor: Exception in task 41.0 in stage 10.0 (TID 3302): java.lang.OutOfMemoryError: Java heap space |
| 13:42:11 | driver | ERROR TaskSchedulerImpl: Lost executor 7 on 10.0.4.21: Command exited with code 52 |
| 13:42:12 | executor 12 | ERROR RetryingBlockTransferor: Exception while beginning fetch of 38 outstanding blocks: java.io.IOException: Failed to connect to /10.0.4.21:43117 |
| 13:42:12 | driver | WARN TaskSetManager: Lost task 3.0 in stage 10.0 (TID 3390): FetchFailed(BlockManagerId(7, 10.0.4.21, 43117), shuffleId=4, mapIndex=17, reduceId=3) |
| 13:42:12 to 13:47:40 | driver and 31 executors | about 4,800 more FetchFailed and connection lines |
Read in time order, the table shows one failure and its cascade. Executor 7 twice failed to get a 64 MB page of execution memory, then threw OutOfMemoryError in task 41 and exited with code 52, which Spark uses for an executor out of heap. Everything after 13:42:09 is cascade: executor 12 was fetching map output that executor 7 had written in stage 9, found nothing listening on port 43117, and the driver recorded a fetch failure. The FetchFailed lines outnumber the heap error thousands to one, but the heap error comes first.
Classifying a death
| Class | First error | What sets it apart |
|---|---|---|
| Memory, heap | `java.lang.OutOfMemoryError: Java heap space` or `GC overhead limit exceeded`; exit code 52 | `Failed to allocate a page` warnings often come first |
| Memory, outside the heap | No Java error; stderr stops mid-line with exit code 137 (SIGKILL), or ends at `RECEIVED SIGNAL TERM` with exit code 143 when the cluster manager sends SIGTERM first | A signal from outside the JVM: the container limit, the cluster manager or the kernel |
| Serialization | `NotSerializableException`, `InvalidClassException ... local class incompatible`, or `ClassNotFoundException` while reading a task | The same task fails the same way on every attempt, and the executor stays up |
| Network | `FetchFailedException`, `Connection reset by peer` or `RpcTimeoutException`, with nothing earlier on the source executor | Failures follow a host rather than a task |
Heartbeat timeouts need extra care. Each executor reports to the driver every 10 seconds, and after 120 seconds of silence, the default spark.network.timeout, the driver logs Removing executor 5 with no recent heartbeats and drops it. That line names no cause, and a frequent one is memory: an executor trapped in back-to-back full collections stops heartbeating while its network is fine. Before filing a timeout under network, open the silent executor's stderr and read the 2 minutes before it went quiet.
The order to read in
- Driver log: find the first line naming a lost executor, and note its ID, host and time.
- That executor's stderr: start 2 minutes before the loss and read forward.
- Stop at the first ERROR, or the first WARN that repeats. That line sets the class.
- Treat everything later, on any machine, as cascade until it proves otherwise.
A job fails at 03:10. The driver log holds 1,900 FetchFailed lines naming host 10.0.6.14, plus a single line at 03:08:55: Removing executor 22 with no recent heartbeats: 131402 ms exceeds timeout 120000 ms. Executor 22 ran on 10.0.6.14, and its stderr ends at 03:06:41 after 3 repeats of Failed to allocate a page (67108864 bytes), try again. How do you classify the death?
- Network: the FetchFailed lines all name 10.0.6.14, and the driver lost contact with executor 22.
- Serialization: executor 22 kept failing to allocate, so its tasks could not write their records.
- Memory: page allocation failed before the heartbeats stopped, so the timeout and fetch failures are cascade.
- Network: heartbeats travel over the network, so a timeout means the link to 10.0.6.14 dropped.
About this lesson
This section is part of the The Spark UI: Advanced lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.