James Xu created SPARK-61252:
--------------------------------
Summary: Add a config to cancel a query when its shuffle write
exceeds a limit
Key: SPARK-61252
URL: https://issues.apache.org/jira/browse/SPARK-61252
Project: Spark
Issue Type: New Feature
Components: SQL
Affects Versions: 5.0.0
Reporter: James Xu
Problem
Spark provides no bound on how much shuffle data a single query may write. A
query whose plan regresses - a missing or wrong join predicate that turns into
a cross join, a low-cardinality or skewed key, or a filter dropped after a
schema change - can write unbounded shuffle to disk, keep running until it
completes, and exhaust shuffle space or memory for other jobs on the cluster.
For example, a self-join whose join key collapses to few distinct values:
SELECT a.user_id, count(*)
FROM serving_log a
JOIN serving_log b
ON a.model = b.model
GROUP BY a.user_id
When `model` has very few distinct values this becomes a near-cartesian product
and a far larger shuffle than intended, with no mechanism to stop it early.
Proposed change
Add an opt-in cap, `spark.sql.maxShuffleWriteBytes`, on the cumulative
shuffle-write bytes of a single SQL execution. A `SparkListener` sums the
shuffle-write bytes of successful tasks per root SQL execution; once the cap is
crossed, the offending jobs are cancelled with a descriptive reason. When the
config is unset the guard is disabled.
Add `spark.sql.maxShuffleWriteBytes.stopApplication` (default false) so that
exceeding the cap stops the whole application instead of cancelling only the
query, letting batch pipelines fail fast rather than continue with a cancelled
job.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]