Loading Academy Hub...
Master enterprise failure forensics: Spark UI event timeline triage, identifying executor vs driver OOM crashes, diagnosing data skew and disk spills, and resolving cluster node degradation.
[!NOTE] Master data engineers are distinguished by their ability to open the Spark UI and instantly pinpoint memory bottlenecks, skewed partitions, and JVM garbage collection stalls.
ConcurrentAppendException, SparkOutOfMemoryError, & Spill Diagnostics in Spark UIConcurrentAppendException / ProtocolChangedException: Happens when two jobs modify overlapping partitions/files without Row-Level Concurrency. Ensure delta.enableDeletionVectors = true, partition/cluster writes cleanly (MERGE ... ON target.date = source.date with explicit static partition predicates!), and serialize schema-evolution ALTER runs.toPandas(), collect(), display() on millions of rows, or massive broadcast() hints (autoBroadcastJoinThreshold set too high). If Executors spill (Spill (Memory) vs Spill (Disk) in Spark UI Stage tab), inspect Skew (Max vs Median task duration) and Executor MemoryOverhead (especially for PySpark Arrow/Pandas UDFs!).Photon metrics, rows output, peak memory) rather than guessing—if a single SortMergeJoin node reads 20x rows on one partition, fix the skew key (NULL / default "-1" join amplification!) immediately.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
from pyspark.sql.functions import col, concat, lit, rand
# Identify skewed key distribution
df.groupBy("merchant_id").count().orderBy(col("count").desc()).show(10)
# Salting technique to eliminate Spark UI straggler task
# Add random salt (0-9) to distribute high-volume merchant across 10 executors
salted_df = df.withColumn("salt", (rand() * 10).cast("int")) \
.withColumn("salted_key", concat(col("merchant_id"), lit("_"), col("salt")))
# Explode dimension table keys to match salted fact table
# Join executed without single-task bottleneckingorg.apache.spark.SparkException: Job aborted due to stage failure: Task 42 in stage 3.0 failed 4 times. ExecutorLostFailure (Container killed by YARN for exceeding memory limits. 14.5 GB of 14.0 GB physical memory used).