VAYUFailure Labs
Colour theme
Investigate a failure

VAYU FAILURE LABS · DISCLOSED SYNTHETIC SCENARIO

Browse all labs

Spark hot-key shuffle skew

LAB 02 · SPARK

One partition is enormous.
The cluster is not the first thing to change.

Synthetic case8–10 minutesMedium difficulty

THE FAILURE

A daily customer aggregate loses an executor with java.lang.OutOfMemoryError: Java heap space.

THE CONSTRAINT

The same code completes on most days. Adding one executor did not move the failing task.

YOUR JOB

Use the stage shape to decide whether this is broad memory pressure or one uneven key.

JOB EXCERPT

Relevant transformation only

daily_metrics.py
events = spark.read.parquet("s3://analytics/events")

daily_customer_metrics = (
    events
      .filter(F.col("event_date") == run_date)
      .groupBy("customer_id")
      .agg(
          F.count("*").alias("events"),
          F.sum("amount").alias("revenue"),
      )
)

The aggregate causes a shuffle: matching customer_id values must meet in the same partition.

EVIDENCE TRAIL

Open the signals in order

0 of 3 signals reviewed
01Failed stageDid every task run out of memory?
Stage 41 · 200 tasks
Median shuffle read: 118 MB
Task 184 shuffle read: 7.6 GB
Task 184: ExecutorLostFailure (java.lang.OutOfMemoryError)
199 tasks completed successfully

This is not an even cluster-wide shortage. One reduce task received far more data than the rest.

02Key sampleWhat filled the oversized partition?
customer_id     rows in the run
unknown         18,402,119
cust_8421           22,104
cust_1109           21,889
other values      < 20,000 each

The fallback value unknown is acting as one customer. All of those rows hash to one shuffle partition.

03Run comparisonWhat changed on the failing date?

The normalisation job that populates customer_id was late. The upstream source therefore emitted the fallback value for 61% of this run.

Reference: Apache Spark SQL performance tuning.

LIKELY ROOT CAUSEA fallback customer key created one hot shuffle partition; executor memory is the symptom, not the first cause.

The job concentrates millions of unrelated events under a single key. More executor memory can delay the same failure, but it does not make that partition balanced.

−.groupBy("customer_id")
+.filter((F.col("customer_id").isNotNull()) & (F.col("customer_id") != "unknown"))

REVIEW BEFORE APPLYINGDo not silently drop a valid business bucket. Quarantine these rows or give them a deliberate reporting path, then repair the late enrichment that created them.

What this lab teaches: the distribution of work matters as much as the size of work. Check the largest partition before resizing the cluster.

WHEN THE FAILURE IS YOURS

Bring the real context.
Keep the review step.

VAYU investigates the code and logs you explicitly submit. It never executes them.

Start a free investigation