-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-53413][SQL] Shuffle cleanup for commands #52157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
616b5e3
602dfb1
6cef7bd
6850ebf
4fa440c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Fix
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ import org.apache.spark.internal.config.{SPARK_DRIVER_PREFIX, SPARK_EXECUTOR_PRE | |
| import org.apache.spark.internal.config.Tests.IS_TESTING | ||
| import org.apache.spark.sql.classic.SparkSession | ||
| import org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec | ||
| import org.apache.spark.sql.execution.datasources.v2.V2CommandExec | ||
| import org.apache.spark.sql.execution.exchange.ShuffleExchangeLike | ||
| import org.apache.spark.sql.execution.ui.{SparkListenerSQLExecutionEnd, SparkListenerSQLExecutionStart} | ||
| import org.apache.spark.sql.internal.SQLConf | ||
|
|
@@ -68,6 +69,17 @@ object SQLExecution extends Logging { | |
| } | ||
| } | ||
|
|
||
| private def extractShuffleIds(plan: SparkPlan): Seq[Int] = { | ||
| plan match { | ||
| case ae: AdaptiveSparkPlanExec => | ||
| ae.context.shuffleIds.asScala.keys.toSeq | ||
| case nonAdaptivePlan => | ||
| nonAdaptivePlan.collect { | ||
| case exec: ShuffleExchangeLike => exec.shuffleId | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Wrap an action that will execute "queryExecution" to track all Spark jobs in the body so that | ||
| * we can connect them with an execution. | ||
|
|
@@ -177,13 +189,10 @@ object SQLExecution extends Logging { | |
| if (queryExecution.shuffleCleanupMode != DoNotCleanup | ||
| && isExecutedPlanAvailable) { | ||
| val shuffleIds = queryExecution.executedPlan match { | ||
| case ae: AdaptiveSparkPlanExec => | ||
| ae.context.shuffleIds.asScala.keys | ||
| case nonAdaptivePlan => | ||
| nonAdaptivePlan.collect { | ||
| case exec: ShuffleExchangeLike => | ||
| exec.shuffleId | ||
| } | ||
| case command: V2CommandExec => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about other commands?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have handled the DataWritingCommandExec, |
||
| command.children.flatMap(extractShuffleIds) | ||
| case plan => | ||
| extractShuffleIds(plan) | ||
| } | ||
| shuffleIds.foreach { shuffleId => | ||
| queryExecution.shuffleCleanupMode match { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of calling
executePlan, can we constructQueryExecutioninstance directly? I feel thisexecutePlanmethod is a bit useless.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have been introduced here. It doesnt mention the rationale behind. But like you mentioned it does nt serve any real purpose, creating new QueryExecution