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.

TimeWhereLine
13:42:03executor 7WARN TaskMemoryManager: Failed to allocate a page (67108864 bytes), try again.
13:42:05executor 7WARN TaskMemoryManager: Failed to allocate a page (67108864 bytes), try again.
13:42:09executor 7ERROR Executor: Exception in task 41.0 in stage 10.0 (TID 3302): java.lang.OutOfMemoryError: Java heap space
13:42:11driverERROR TaskSchedulerImpl: Lost executor 7 on 10.0.4.21: Command exited with code 52
13:42:12executor 12ERROR RetryingBlockTransferor: Exception while beginning fetch of 38 outstanding blocks: java.io.IOException: Failed to connect to /10.0.4.21:43117
13:42:12driverWARN 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:40driver and 31 executorsabout 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

ClassFirst errorWhat 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 heapNo 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 firstA 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 taskThe 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 executorFailures 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

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?

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.