xumingming opened a new pull request, #60243: URL: https://github.com/apache/spark/pull/60243
### What changes were proposed in this pull request? Add two opt-in SQL configurations: - `spark.sql.maxShuffleWriteBytes`: an optional cap on the cumulative shuffle-write bytes of a single SQL execution. A `SparkListener` registered in `SharedState` sums the shuffle-write bytes of successful tasks per root execution; once the cap is crossed, the offending jobs are cancelled with a descriptive reason. When unset, the guard is disabled. - `spark.sql.maxShuffleWriteBytes.stopApplication`: when true, exceeding the cap stops the whole application instead of cancelling only the query. ### Why are the changes needed? 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 becomes a cross join, a low-cardinality or skewed key, or a dropped filter) can write unbounded shuffle to disk and destabilize other jobs on the cluster. This adds a circuit breaker that cancels the offending query, or stops the application, once a threshold is crossed. ### Does this PR introduce _any_ user-facing change? Yes. Two new SQL configurations, `spark.sql.maxShuffleWriteBytes` and `spark.sql.maxShuffleWriteBytes.stopApplication`, control a new kill switch. Both are disabled by default, so existing behavior is unchanged. ### How was this patch tested? Added `MaxShuffleWriteBytesListenerSuite` and `MaxShuffleWriteBytesListenerStopApplicationSuite`. ``` build/sbt 'sql/testOnly *MaxShuffleWriteBytesListenerSuite *MaxShuffleWriteBytesListenerStopApplicationSuite' ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
