What you will be able to do
- Say what a Spark driver log, executor (worker) log and compute event log each contain, and which one to open for a given failure
- Follow a failed task from its job and stage to the executor whose log4j output explains it
- Set up log delivery to a Volumes, S3 or DBFS path, and export metrics to outside tools
- Tell an executor out-of-memory error from a driver out-of-memory error, and choose a fix for each
- Spot an underused cluster from CPU, task and timeline metrics: idle cores, too few tasks, or work stuck on the driver
Key concept
The log follows the process — A Spark application runs as one driver process and many executor processes, and each one writes its own log. Your print statements, exception stack traces and scheduling messages go to the driver log. A task's own output and failures go to the log of the executor that ran it. To diagnose a failure, first work out which process failed, then read that process's log.
1.What driver logs and executor logs contain
Spark writes one log for the driver and one for each executor because they are separate processes. Driver, worker nodes, executors and the cluster manager covers what those roles do. When something fails, the first question is which process failed, because only that process's log has the evidence.
The driver log records the application's control flow. Print and log statements from notebooks, jobs and libraries all land there, in three outputs: standard output, standard error and Log4j logs. If a query never starts, or a streaming job dies during startup, open the driver log to find the exception's stack trace. You open driver logs from the Driver logs tab on the compute details page, and you can download each file.
The executor log, also called the worker log, is narrower. It is what you read when particular tasks misbehave and you want the output from those tasks, because that output was written on the worker that ran them. You reach worker logs through the Spark UI, not the Driver logs tab.
A third log covers different ground. The compute event log records lifecycle events for the cluster as a whole: creation, termination, configuration edits and resizing. It keeps events for 60 days. Autoscaling history and node provisioning live here, not in the driver or executor logs.
| Log | What it captures | Where you open it |
|---|---|---|
| Compute event log | Lifecycle events: creation, termination, configuration edits, resizing | Event log tab on the compute details page |
| Spark driver log | print and log statements from notebooks, jobs and libraries; exception stack traces (standard output, standard error, Log4j) | Driver logs tab on the compute details page |
| Spark worker (executor) log | Log4j output for the tasks that ran on that worker | Spark UI tab, from the Executors table or the worker page |
Who can read these logs depends on the compute's access mode. On Standard access mode, only workspace admins can see driver logs, and executor logs are not available at all. On Dedicated access mode, the assigned user or group and workspace admins can read both.
Checkpoint 1 of 9· Match them up
A Spark job on classic compute is misbehaving. Match each log to the evidence you would go there to find.
Tap a term, then the definition that fits it.
Lifecycle events for the whole cluster, such as resizing and configuration edits, go to the compute event log. Print statements and startup exceptions go to the driver log. Output from individual tasks stays in the log of the worker that ran them.
“Compute event logs, which capture compute lifecycle events like creation, termination, and configuration edits.”Source: docs.databricks.com
Checkpoint 2 of 9· Exam question
In a Databricks cluster, which statement correctly distinguishes the purpose of driver logs from executor logs when diagnosing a failed Spark application?
Correct answer: A — Driver logs capture the driver process's control-flow output — Python tracebacks, notebook print statements, and scheduler messages — while executor logs capture per-task standard output and JVM errors from the worker nodes running the computation.
- A. This matches how Spark instruments the two processes: the driver runs the user's program and scheduler, so its logs surface driver-side exceptions and print output, while each executor runs assigned tasks, so its logs surface task-level errors such as out-of-memory failures on that worker.
- B. Garbage collection pauses are recorded for both the driver and every executor JVM, not just the driver, and query plans generated by Catalyst are visible through
explain()output and the Spark UI's SQL tab rather than being confined to the executor logs. - C. Shuffle read and write metrics are collected per task and surfaced through the Stages tab of the Spark UI and the executor logs where those tasks ran, not through the driver logs, and DAG visualization data is UI rendering, not raw executor log content.
- D. Both driver and executor logs are produced in local mode and in cluster mode; local mode simply runs the driver and a single executor in the same JVM, so the distinction between the two log types still applies to whichever processes exist, not to the deployment mode itself.
- E. Cluster autoscaling and node provisioning events are surfaced through the cluster event log in the Databricks UI, and Delta Lake transaction log entries are stored as JSON files in the table's
_delta_logdirectory, not written into either driver or executor application logs.
2.Following a failed task to its executor's log
A failure that happens inside a task is recorded on whichever executor ran it, so you trace it down the Application → job → stage → task hierarchy until you have an executor ID. In the Spark UI, the path goes like this:
- Open the Jobs tab and click the failed job's description.
- In that job's stages table, click the failing stage. The failure reason appears there, and further down the page shows why each task failed.
- In the stage's task list, note the Task ID and Executor ID of the task you care about.
- Open the Executors tab, find the row with that Executor ID, and open its logs or its thread dump.
A thread dump is a snapshot of every thread's state in a JVM. Use one when a task hangs or runs slowly, not when it has failed. In the executor's thread dump, the task's thread is the one whose name contains TID followed by the task ID. A finished task has no thread left to match. The driver row in the Executors table has its own Thread Dump link. Use it when the driver seems to hang, for example when no Spark progress bars appear or they sit at 100%.
The task has finished, or it is no longer running on that executor. A thread dump only shows live threads, so a task that has finished has no matching thread. Go back to the stage's task list and check the task's status and its current executor ID.
Checkpoint 3 of 9· Check yourself
Your notebook query has shown its Spark progress bars stuck at 100% for ten minutes, and the query never returns. Which Spark UI view should you open first to see what is blocking?
Progress bars stuck at 100% mean the driver is making no progress, so you open the driver's own thread dump from its row in the Executors table. An executor thread dump only helps with a task that is still running and is hanging or slow, and here the tasks have already finished.
“making no progress on queries (for example, Spark progress bars are stuck at 100%). To view the driver's thread dump in the Spark UI:”Source: docs.databricks.com
3.Publishing logs and exporting metrics
Driver and worker logs in the UI belong to the running compute. After you restart a terminated cluster, the Spark UI shows the restarted compute, not the run you were trying to debug. To keep logs after a cluster is gone, set up cluster log delivery when you create or edit the compute. Under Advanced, open the Logging tab, choose a destination type, and enter a log path. Delivery covers the Spark driver logs, the worker node logs and the event logs.
Three destinations are available. Volumes (a Unity Catalog volume path) is the recommended and most secure choice on Unity Catalog-enabled compute. S3 writes to a bucket path. DBFS is legacy, and you can only use it if DBFS root and mounts are not disabled for the workspace. Logs are delivered every five minutes and archived hourly. Each cluster gets its own subfolder named after its cluster_id, so a log path of /Volumes/catalog/schema/volume receives files under /Volumes/catalog/schema/volume/06308418893214. Delivering to a volume requires the compute owner or assigned user to have READ VOLUME and WRITE VOLUME on it. It does not work with Dedicated access mode assigned to a group.
What appears in the driver log is partly up to you. Every print and log statement in your code ends up there, which makes it the natural place to record row counts, parameters and checkpoints from your own logic. For centralized observability, Spark metrics can be exported to external monitoring systems. One documented route is to install a Datadog agent on every node with a compute-scoped init script, and to manage that script through a compute policy so it reaches all compute. For quick analysis without an agent, each chart in the compute Metrics tab has a Download CSV or Download Excel option. The By node view is the exception.
Checkpoint 4 of 9· Check yourself
Nightly runs use job compute that terminates when each run ends. The team wants to read the driver and executor logs from any run days later. What should they set up?
Logs shown in the UI belong to the running compute, and a restarted cluster shows the new run instead of the old one. Cluster log delivery copies driver, worker and event logs to a destination such as a volume, where they remain after the cluster terminates. The compute event log records only lifecycle events, and the Datadog agent exports metrics.
“You can also configure a log delivery location for the compute. Both worker and compute logs are delivered to the location you specify.”Source: docs.databricks.com
4.Diagnosing executor out-of-memory errors
An executor that runs out of memory doesn't fail cleanly. Spark removes it and retries its tasks on other executors. The job slows down, and once the same task has failed enough times, the stage and then the job fail. In the driver log, the message usually looks like this:
SparkException: Job aborted due to stage failure: Task 3 in stage 0.0 failed 4 times, most recent failure: Lost task 3.3 in stage 0.0 (TID 30) (10.139.64.114 executor 4): ExecutorLostFailure (executor 4 exited caused by one of the running tasks) Reason: Remote RPC client disassociated. Likely due to containers exceeding thresholds, or network issues. Check driver logs for WARN messages.The error message alone does not prove a memory problem. The three most common reasons executors are removed are autoscaling (expected, not an error), spot instance losses, and running out of memory. Rule out the first two in the compute event log. If it explains nothing, open the Executors tab in the Spark UI and read the failed executors' logs. By then, memory is the most likely explanation.
To confirm, double the memory per core and run the job again. For example, swap a 4-core, 16 GB worker for a 4-core, 32 GB worker, which gives 8 GB per core instead of 4. A worker with twice the cores and twice the memory tests nothing, because the ratio stays the same. If the job fails later or not at all, memory was the cause. This is the practical form of Executor and driver memory, spill and cluster sizing: you raise executor memory relative to cores, not the cluster's total. While the job runs, the JVM heap usage chart on the Metrics tab shows heap use against its configured maximum. Heap that stays close to the limit is an early warning, and the long pauses it causes are covered in JVM garbage collection in executors.
If more memory doesn't help, or costs too much, look in the code. The common causes are:
- too few shuffle partitions (set
spark.sql.shuffle.partitionstoauto) - a broadcast join hint on a large table
- UDFs that load a whole partition into memory
- a window function with no
PARTITION BY - skew
- unbounded streaming state
Skew deserves particular attention because adding cluster memory does not fix it. When a few key values hold most of the rows, the one task that receives them has to process its whole partition while the others finish in seconds. A stage where one task reads 40 GB of shuffle data and the rest read 200 MB each will run that task out of memory however much RAM the other executors have. You confirm skew in the stage's Summary Metrics: if the Max duration exceeds the 75th percentile by 50% or more, the stage might be skewed. For an aggregation, the fix is to salt the hot keys, which means adding a random bucket suffix, then group and aggregate in two stages. For sort-merge and shuffle-hash joins, adaptive query execution can split skewed partitions automatically. Identifying and reducing data skew and Adaptive Query Execution cover those fixes in detail.
Checkpoint 5 of 9· Put it in order
Executors keep disappearing and stages fail with ExecutorLostFailure. Put these diagnostic steps in the order the lesson recommends.
- 1.If more memory doesn't help or costs too much, look in the code for causes such as too few shuffle partitions, a broadcast hint on a large table, or skew
- 2.Open the Executors tab in the Spark UI and read the logs of the failed executors
- 3.Rerun the job on a worker type with double the memory per core, for example 4 cores and 32 GB instead of 4 cores and 16 GB
- 4.Check the compute event log for autoscaling resizes or spot instance losses that explain the removed executors
Autoscaling and spot losses also remove executors, so you rule them out in the event log before suspecting memory. Only then do you read the failed executors' logs and confirm by doubling memory per core. Code-level causes come last, when extra memory doesn't fix the problem or costs too much.
“To find out why your executors are failing, first check the compute's Event log to see whether there's an explanation for the executor failures.”Source: docs.databricks.com
Checkpoint 6 of 9· Exam question
A PySpark job aggregates web clickstream data and consistently fails with executor OutOfMemoryError exceptions, even though the cluster has ample total memory. The Spark UI's Stages tab shows one task in the failing stage processing 40 GB of shuffle data while the other 199 tasks in the same stage each process under 200 MB:
clicks = spark.read.parquet("/mnt/clickstream/events")
sessions = clicks.groupBy("session_id").agg(collect_list("page").alias("pages"))
sessions.write.format("delta").mode("overwrite").save("/mnt/gold/sessions")
What is the most likely root cause, and which change addresses it?
Correct answer: A — A small number of session_id values account for a disproportionate share of the clicks, so one task inherits far more rows than the rest; salting the skewed keys or enabling adaptive skew join handling redistributes that task's work across more partitions.
- A. Uneven task sizes in the Stages tab, where one task's shuffle input dwarfs the rest, is the classic signature of data skew on the grouping key, and mitigations that spread the heavy key's rows across multiple partitions — key salting or Spark's adaptive skewed-join handling — directly relieve the executor that would otherwise run out of memory.
- B. The described symptom is skew in the shuffle stage that produces
sessions, which happens before the write step even begins; changing how many records go into each output file changes the shape of the Delta write, not the distribution of work in the precedinggroupByaggregation. - C. Adaptive query execution is enabled by default in current Spark releases and already targets this exact scenario through its skewed-join optimization, but that optimization applies to joins, and there is no configuration named
spark.sql.adaptiveJoinEnabledthat converts agroupByaggregation into a broadcast operation. - D.
collect_listruns as an executor-side aggregation like any other grouped function and does not inherently ship its output to the driver; the failure here is an executor-levelOutOfMemoryErrortied to one task's data volume, which points to skew rather than to a driver-bound aggregation function. - E. Row group layout in the source Parquet files affects how Spark splits input for reading, but the failure occurs later, in the shuffle stage produced by
groupBy("session_id"), and the uneven task sizes reported there are keyed bysession_idvalues, not by how the upstream files were originally written.
5.Diagnosing driver out-of-memory errors and hangs
A driver out-of-memory error shows up in the driver log, not in an executor log, and the usual cause is code that pulls a large result into the driver. collect() returns every row as a list, and its documentation warns that all the data is loaded into the driver's memory. toPandas() does the same, with or without Arrow. As Bringing rows to the driver (collect, take, toLocalIterator, toPandas) explains, these calls are safe only when the result is small.
Consider a groupBy("region").agg(...) that produces two million rows, followed by collect() on an 8 GB driver. The aggregation runs fine on the executors. It is the last step, sending all two million rows to one process, that fills the driver heap. Steps taken on the executors before that point leave the amount collected unchanged:
repartition(200)splits the same rows into more pieces, and they all still reach the driver.- Persisting the DataFrame changes where executors keep it, and the driver still receives every row.
- Rewriting the aggregation as
reduceByKey(...).collect()still collects one row per region.
The fix that works is to keep the full result off the driver: write it out with the DataFrame writer, then look at a small sample with limit(...) and show().
Raising driver memory is a reasonable first step when the driver is short of resources in general. When many concurrent streams or jobs crash the driver, check its CPU, memory and disk in the metrics. Adjust driver sizing, then make sure your code isn't running memory-intensive work or UDFs on the driver. If you can't scale the driver up any further, split the work across clusters. A bigger heap does not help when the result to be collected keeps growing with the data.
Not every driver failure produces an exception. If the driver appears hung, for example with no progress bars or bars stuck at 100%, open the driver row's thread dump in the Executors tab. It shows what each driver thread is doing at that moment.
Checkpoint 7 of 9· Check yourself
Twelve streaming queries run on one classic cluster, and its driver keeps crashing. The metrics show the driver's CPU and memory maxed out while the workers are mostly idle. The driver is already the largest node type available. What should you do next?
The driver is the bottleneck, and it can't be made any bigger. The remaining fix is to split the concurrent workloads across clusters so that each driver has less to coordinate. Changing the workers does nothing for an overloaded driver.
“Spread the load over multiple clusters. Move some of the concurrent workloads to separate compute so that each driver coordinates less work.”Source: docs.databricks.com
Checkpoint 8 of 9· Exam question
A data engineer runs the following PySpark job on a Databricks all-purpose cluster and the driver fails with java.lang.OutOfMemoryError: Java heap space. The transactions table produces roughly two million distinct region values after the aggregation below, and the driver is provisioned with 8 GB of memory:
df = spark.read.parquet("/mnt/sales/transactions")
results = df.groupBy("region").agg(sum("amount").alias("total"))
rows = results.collect()
for row in rows:
print(row)
Which change most directly resolves the driver OutOfMemoryError while still letting the engineer inspect the aggregated totals?
Correct answer: A — Write results to a Delta table with results.write.format("delta").mode("overwrite").save(path), then read back only a sample of rows with spark.read.format("delta").load(path).limit(20).show() instead of collecting everything.
- A. Persisting the aggregated result to storage and then reading back a bounded sample keeps the full two million rows out of the driver heap entirely, which is what a plain
collect()call cannot avoid regardless of how the DataFrame was partitioned upstream. - B. The failure happens because
collect()serializes every row ofresultsinto the driver's JVM heap in one operation; raising driver memory only postpones the failure to a larger dataset and does nothing to change the underlying pattern of pulling all rows into one process. - C. Partitioning affects how work is distributed across executors during the shuffle that produces
results, butcollect()still gathers every partition's rows into the driver afterward, so repartitioning the aggregated DataFrame does not reduce what lands in driver memory. - D. Switching to the RDD API changes how the reduction executes on the cluster, but the final
collect()call in this alternative still pulls the same two million aggregated key-value pairs into the driver, so the out-of-memory condition remains unresolved. - E.
persist()controls how a DataFrame's data is cached across executors for reuse in later stages, but it has no effect on what happens whencollect()is subsequently called — that operation still copies every resulting row into the driver's memory.
6.Diagnosing an underused cluster
An underused cluster is one where you pay for executors that sit idle. The metrics show it before any error appears. Each core runs one task at a time, as covered in CPU cores as task slots (parallelism). So underutilization always means there are more free task slots than runnable tasks. It has three common causes, and each leaves a different signature.
Work stuck on the driver. When the driver is overloaded, it cannot hand out tasks fast enough, so the executors sit idle. The sign is long gaps in the Spark UI jobs timeline, with heavy driver load and lightly loaded workers in the cluster metrics. Non-Spark code, such as a Python loop calling native Python functions, runs entirely on the driver. Too many concurrent streams or threaded jobs, and many attached notebooks, also add to the driver's load.
Too few tasks. Sort a long job's stages by duration and check the task count of the longest one. A single task means the stage runs with no parallelism: one core works while the rest of the cluster waits. A common example is a window function with no PARTITION BY.
Uneven tasks. With skew, one or a few tasks run far longer than the rest, and the other cores go idle while those tasks finish. Even when tasks are evenly sized, check which executors ran them. A single receiver can leave one executor doing all the work on a cluster that has several.
The Metrics tab of the compute gives the numbers behind these patterns. The CPU utilization chart splits CPU time by mode, and idle is time the CPU had nothing to do. Active tasks counts the tasks running at any moment. Compare it with the cluster's total cores to see how many slots are empty. Server load distribution shows each node's CPU over the last minute, and the By node view puts every node on one page so outliers stand out. Spark metrics are not available per node, so check the hardware charts to see whether one node is busy and the others idle. For an overloaded driver, start by doubling the driver size, reduce concurrency, or spread the work across clusters. If the cause is non-Spark code, rewrite that code to use Spark.
Checkpoint 9 of 9· Match them up
Each of these clusters is underused: executors sit idle while you pay for them. Match each signature you find in the Spark UI or metrics to the cause it points to.
Tap a term, then the definition that fits it.
Each cause leaves free task slots in a different way. An overloaded driver can't hand out tasks fast enough. A one-task stage keeps only one core busy. Skewed tasks leave the other cores waiting for them to finish. A single receiver can concentrate evenly sized work on one executor.
“When the driver is overloaded, it can't hand out work fast enough, so the executors sit idle while you still pay for them.”Source: docs.databricks.com
Sources
(13)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“The direct print and log statements from your notebooks, jobs, and libraries go to the Spark driver logs.”
↩︎ What driver logs and executor logs contain“Compute event logs, which capture compute lifecycle events like creation, termination, and configuration edits.”
↩︎ What driver logs and executor logs contain“You can install Datadog agents on compute nodes to send Datadog metrics to your Datadog account.”
↩︎ Publishing logs and exporting metrics“If you restart a terminated compute, the Spark UI displays information for the restarted compute, not the historical information for the terminated compute.”
↩︎ Publishing logs and exporting metrics“The direct print and log statements from your notebooks, jobs, and libraries go to the Spark driver logs.”
↩︎ Key concept“Compute event logs, which capture compute lifecycle events like creation, termination, and configuration edits.”
↩︎ Exam trap 1“You can also configure a log delivery location for the compute. Both worker and compute logs are delivered to the location you specify.”
↩︎ Checkpoint - 2.
“You can drill into the Driver logs to look at the stack trace of the exception.”
↩︎ What driver logs and executor logs contain“Executor logs are helpful if you see certain tasks are misbehaving and would like to see the logs for specific tasks.”
↩︎ What driver logs and executor logs contain“Executor logs are not available for compute with Standard access mode.”
↩︎ What driver logs and executor logs contain“find the target task that corresponds to the thread dump you want to see, and note its Task ID and Executor ID values”
↩︎ Following a failed task to its executor's log“Thread dumps are useful in debugging a specific hanging or slow-running task.”
↩︎ Following a failed task to its executor's log“Thread dumps are also useful for debugging issues where the driver appears to be hanging”
↩︎ Diagnosing driver out-of-memory errors and hangs“Ensure that the tasks are executed on multiple executors (nodes) in your compute to have enough parallelism while processing.”
↩︎ Diagnosing an underused cluster“making no progress on queries (for example, Spark progress bars are stuck at 100%). To view the driver's thread dump in the Spark UI:”
↩︎ Checkpoint - 3.
“Here you can get the logs from the failed executors:”
↩︎ Following a failed task to its executor's log“Autoscaling: In this case it's expected and not an error.”
↩︎ Diagnosing executor out-of-memory errors“first check the compute's Event log to see whether there's an explanation for the executor failures”
↩︎ Prediction“To find out why your executors are failing, first check the compute's Event log to see whether there's an explanation for the executor failures.”
↩︎ Checkpoint - 4.https://docs.databricks.com/aws/en/compute/configureOfficial docs
“Logs are delivered every five minutes and archived hourly in your selected destination.”
↩︎ Publishing logs and exporting metrics“Databricks creates a subfolder in your chosen log path named after the compute's cluster_id.”
↩︎ Publishing logs and exporting metrics - 5.https://docs.databricks.com/aws/en/lakehouse-architecture/operational-excellence/best-practicesOfficial docs
“Configure Spark metrics to export to external monitoring systems for centralized observability.”
↩︎ Publishing logs and exporting metrics - 6.
“When executors run out of memory, Spark removes them and retries their tasks.”
↩︎ Diagnosing executor out-of-memory errors“The ratio of memory to cores matters, not the total memory.”
↩︎ Diagnosing executor out-of-memory errors“These errors are often generic, and other issues might cause them.”
↩︎ Exam trap 2“The ratio of memory to cores matters, not the total memory.”
↩︎ Exam trap 3 - 7.
“If the Max duration exceeds the 75th percentile by 50% or more, the stage might have skew.”
↩︎ Diagnosing executor out-of-memory errors“append a random bucket suffix to the skewed keys, and then group and aggregate in two stages”
↩︎ Diagnosing executor out-of-memory errors“Skew happens when one or a few tasks take much longer than the rest.”
↩︎ Diagnosing an underused cluster - 8.
“JVM heap usage: The JVM heap memory usage, averaged across all applicable nodes.”
↩︎ Diagnosing executor out-of-memory errors“Active tasks: The total number of tasks executing at any given time.”
↩︎ Diagnosing an underused cluster - 9.
“all the data is loaded into the driver's memory”
↩︎ Diagnosing driver out-of-memory errors and hangs“all the data is loaded into the driver's memory”
↩︎ Exam trap 4 - 10.
“toPandas() results in the collection of all records in the DataFrame to the driver program”
↩︎ Diagnosing driver out-of-memory errors and hangs - 11.
“Avoid calling collect() or other expensive DataFrame operations on the driver unless absolutely necessary”
↩︎ Diagnosing driver out-of-memory errors and hangs - 12.https://docs.databricks.com/aws/en/optimizations/spark-ui-guide/spark-driver-overloadedOfficial docs
“When the driver is overloaded, it can't hand out work fast enough, so the executors sit idle while you still pay for them.”
↩︎ Diagnosing an underused cluster“Spread the load over multiple clusters. Move some of the concurrent workloads to separate compute so that each driver coordinates less work.”
↩︎ Checkpoint“If the driver is busy running non-Spark code, a larger driver doesn't help the idle workers.”
↩︎ Prediction - 13.
“A single task means the stage runs with no parallelism”
↩︎ Diagnosing an underused cluster