Skip to content

[SPARK-52741][SQL] RemoveFiles ShuffleCleanup mode doesnt work with non-adaptive execution #51432

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.exchange.ShuffleExchangeLike
import org.apache.spark.sql.execution.ui.{SparkListenerSQLExecutionEnd, SparkListenerSQLExecutionStart}
import org.apache.spark.sql.internal.SQLConf
import org.apache.spark.sql.internal.StaticSQLConf.SQL_EVENT_TRUNCATE_LENGTH
Expand Down Expand Up @@ -178,8 +179,11 @@ object SQLExecution extends Logging {
val shuffleIds = queryExecution.executedPlan match {
case ae: AdaptiveSparkPlanExec =>
ae.context.shuffleIds.asScala.keys
case _ =>
Iterable.empty
case nonAdaptivePlan =>
nonAdaptivePlan.collect {
case exec: ShuffleExchangeLike =>
exec.shuffleId
}
}
shuffleIds.foreach { shuffleId =>
queryExecution.shuffleCleanupMode match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,19 @@ class QueryExecutionSuite extends SharedSparkSession {
}

test("SPARK-47764: Cleanup shuffle dependencies - RemoveShuffleFiles mode") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that the test has a jira number. Should i create a new test with the jira id used for this change? @dongjoon-hyun please advise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO you can extend the existing tests when the new functionality can be easily covered by those. But why didn't you adjust all SPARK-47764: ... tests?

Copy link
Contributor Author

@karuppayya karuppayya Jul 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peter-toth I modified only SPARK-47764: Cleanup shuffle dependencies - RemoveShuffleFiles mode, since my change was specific to org.apache.spark.sql.execution.RemoveShuffleFiles. I can add negatibve assertions to other and make them consistent . Let me know

Copy link
Contributor

@peter-toth peter-toth Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, your PR affects other ShuffleCleanupModes too so the other 2 should work with both AQE enabled and disabled as well. All you need to do is to wrap those tests into an AQE on/off loop.

val plan = spark.range(100).repartition(10).logicalPlan
val df = Dataset.ofRows(spark, plan, RemoveShuffleFiles)
df.collect()

val blockManager = spark.sparkContext.env.blockManager
assert(blockManager.migratableResolver.getStoredShuffles().isEmpty)
assert(blockManager.diskBlockManager.getAllBlocks().isEmpty)
cleanupShuffles()
Seq(true, false).foreach { adaptiveEnabled => {
withSQLConf((SQLConf.ADAPTIVE_EXECUTION_ENABLED.key, adaptiveEnabled.toString)) {
val plan = spark.range(100).repartition(10).logicalPlan
val df = Dataset.ofRows(spark, plan, RemoveShuffleFiles)
df.collect()

val blockManager = spark.sparkContext.env.blockManager
assert(blockManager.migratableResolver.getStoredShuffles().isEmpty)
assert(blockManager.diskBlockManager.getAllBlocks().isEmpty)
cleanupShuffles()
}
}
}
}

test("SPARK-35378: Return UnsafeRow in CommandResultExecCheck execute methods") {
Expand Down