Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-36036][CORE] Fix cleanup of DownloadFile resources
### What changes were proposed in this pull request? There was a regression since Spark started storing large remote files on disk (https://issues.apache.org/jira/browse/SPARK-22062). In 2018 a refactoring introduced a hidden reference preventing the auto-deletion of the files (a97001d#diff-42a673b8fa5f2b999371dc97a5de7ebd2c2ec19447353d39efb7e8ebc012fe32L1677). Since then all underlying files of DownloadFile instances are kept on disk for the duration of the Spark application which sometimes results in "no space left" errors. `ReferenceWithCleanup` class uses `file` (the `DownloadFile`) in `cleanUp(): Unit` method so it has to keep a reference to it which prevents it from being garbage-collected. ``` def cleanUp(): Unit = { logDebug(s"Clean up file $filePath") if (!file.delete()) { <--- here logDebug(s"Fail to delete file $filePath") } } ``` ### Why are the changes needed? Long-running Spark applications require freeing resources when they are not needed anymore, and iterative algorithms could use all the disk space quickly too. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added a test in BlockManagerSuite and tested manually. Closes #33251 from dtarima/fix-download-file-cleanup. Authored-by: Denis Tarima <dtarima@gmail.com> Signed-off-by: Sean Owen <srowen@gmail.com>
- Loading branch information
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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