[SPARK-59776][CORE][SQL] Notify ExecutorMonitor when SQL shuffle cleanup removes shuffle files - #59054
Open
saurabhdamle11 wants to merge 3 commits into
Open
[SPARK-59776][CORE][SQL] Notify ExecutorMonitor when SQL shuffle cleanup removes shuffle files#59054saurabhdamle11 wants to merge 3 commits into
saurabhdamle11 wants to merge 3 commits into
Conversation
…huffle file cleanup removes shuffle files When SQL shuffle dependency file cleanup is enabled, SQLExecution removes shuffle files via ShuffleDriverComponents.removeShuffle directly, bypassing ContextCleaner, so the dynamic allocation ExecutorMonitor is never told and keeps executors alive for those shuffles (forever with the default infinite shuffle tracking timeout). Add CleanerListener.shuffleFilesRemoved (no-op by default) and ContextCleaner.notifyShuffleFilesRemoved, call it after a successful removal in SQLExecution, and have ExecutorMonitor stop tracking the shuffle. A separate callback is used instead of shuffleCleaned because the shuffle intentionally stays registered on the MapOutputTracker. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n from RemoveShuffleFiles listener test In local mode the driver's BlockManagerStorageEndpoint handles RemoveShuffle and unregisters the shuffle from the MapOutputTrackerMaster, so the shuffle is not guaranteed to stay registered after SQL shuffle file cleanup. Keep only the listener notification assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
When SQL shuffle dependency file cleanup is enabled (
spark.sql.classic.shuffleDependency.fileCleanup.enabled, or theconnect/thriftservervariants),SQLExecution.cleanupShuffleDependenciesremoves a query's shuffle files by callingShuffleDriverComponents.removeShuffledirectly. It doesn't go throughContextCleaner, soCleanerListeners are never told the shuffle is gone.This PR:
CleanerListener.shuffleFilesRemoved(shuffleId), a no-op by default.ContextCleaner.notifyShuffleFilesRemoved(shuffleId), which calls it on all attached listeners.SQLExecutionafter a successfulRemoveShuffleFilescleanup.ExecutorMonitor, so that executors stop tracking the removed shuffle.A new callback is used instead of reusing
shuffleCleaned.shuffleCleanedmeans the shuffle was fully cleaned, including unregistering its map outputs from theMapOutputTracker. This cleanup path deliberately doesn't unregister them, so that stage retries can still be triggered, and existingshuffleCleanedlisteners rely on that meaning.Why are the changes needed?
With
spark.dynamicAllocation.shuffleTracking.enabled,ExecutorMonitorkeeps an executor alive while it holds shuffle data that may still be used. It stops tracking a shuffle only whenContextCleanerreports it cleaned, which happens after theShuffleDependencyis garbage collected on the driver.With SQL shuffle file cleanup enabled, the shuffle files are deleted right after the query finishes, but
ExecutorMonitorisn't told. It keeps executors pinned to shuffles that no longer exist until theShuffleDependencyis eventually garbage collected, which may never happen while the DataFrame is still referenced. With the defaultspark.dynamicAllocation.shuffleTracking.timeout(infinite), those executors are never released even though they hold no shuffle data.Does this PR introduce any user-facing change?
Yes. When SQL shuffle dependency file cleanup and dynamic allocation shuffle tracking are both enabled, executors whose shuffle files were removed by the cleanup are now released after
spark.dynamicAllocation.executorIdleTimeout. Before this change they stayed until the shuffle was garbage collected on the driver, or untilspark.dynamicAllocation.shuffleTracking.timeout. Behavior with the default configuration (file cleanup disabled) is unchanged.How was this patch tested?
New unit tests:
ExecutorMonitorSuite: "SPARK-59776: executor with removed shuffle files times out at the idle deadline". It checks that aftershuffleFilesRemoved, an executor that only held that shuffle times out at the idle timeout instead of the shuffle tracking timeout.SQLExecutionSuite: "SPARK-59776: RemoveShuffleFiles cleanup notifies cleaner listeners". It runs a shuffle join with file cleanup enabled and checks thatshuffleFilesRemovedfires for every shuffle in the plan and thatshuffleCleaneddoesn't.All tests passed on GitHub Actions: https://github.com/saurabhdamle11/spark/actions/runs/36168154179
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
Title: [SPARK-59776][CORE][SQL] Release shuffle-tracked executors when SQL shuffle file cleanup removes shuffle files