-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-21721][SQL] Clear FileSystem deleteOnExit cache when paths are successfully removed #18934
Conversation
Test build #80609 has finished for PR 18934 at commit
|
There is a test which doesn't drop the table it created... |
8912397
to
976e288
Compare
Test build #80614 has finished for PR 18934 at commit
|
Test build #80613 has finished for PR 18934 at commit
|
retest this please. |
Test build #80621 has finished for PR 18934 at commit
|
createdTempDir.foreach { path => | ||
path.getFileSystem(hadoopConf).delete(path, true) | ||
// If we successfully delete the staging directory, remove it from FileSystem's cache. | ||
val fs = path.getFileSystem(hadoopConf) |
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.
You call getFileSystem twice; you can reuse it.
I suppose this adds an additional check to see if the file exists, but this won't be called that often.
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.
Oh. right. Thanks.
|
||
orders.toDF.createOrReplaceTempView("orders1") | ||
orderUpdates.toDF.createOrReplaceTempView("orderupdates1") | ||
withTable("orders", "orderupdates") { |
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.
Is this intended to be part of this PR?
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.
The newly added test has been bitten by an existing test which doesn't drop created table. Those old tests all don't drop created tables. I can move them to another minor PR if you think it's necessary.
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.
Usually, each test case should be independent. Could you isolate your new test case instead? It would be better when we backport your PR later.
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.
Yes. Please revert all the unrelated changes.
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.
OK.
Test build #80627 has finished for PR 18934 at commit
|
createdTempDir.foreach { path => path.getFileSystem(hadoopConf).delete(path, true) } | ||
createdTempDir.foreach { path => | ||
val fs = path.getFileSystem(hadoopConf) | ||
fs.delete(path, true) |
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.
FileSystem.delete returns true if delete is successful else false.
So it makes sense to re-write a bit
if (fs.delete(path, true)) {
fs.cancelDeleteOnExit(path)
}
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.
Great. Thanks.
Test build #80649 has finished for PR 18934 at commit
|
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.
+1, LGTM.
LGTM |
… successfully removed ## What changes were proposed in this pull request? We put staging path to delete into the deleteOnExit cache of `FileSystem` in case of the path can't be successfully removed. But when we successfully remove the path, we don't remove it from the cache. We should do it to avoid continuing grow the cache size. ## How was this patch tested? Added a test. Author: Liang-Chi Hsieh <viirya@gmail.com> Closes #18934 from viirya/SPARK-21721. (cherry picked from commit 4c3cf1c) Signed-off-by: gatorsmile <gatorsmile@gmail.com>
Thanks! Merging to master/2.2 |
Tried to merge to Spark 2.1, but I hit a conflict. Thus, please let me know if anybody wants it in 2.1. Thanks! |
Please try to fix it in 2.1 too. We have a product running on this version Spark. Thanks a lot! |
cc @viirya |
@yzheng616 @gatorsmile Ok. I will backport it to 2.1. |
sql("CREATE TABLE test21721 (key INT, value STRING)") | ||
val pathSizeToDeleteOnExit = setOfPath.size() | ||
|
||
(0 to 10).foreach(_ => testData.write.mode(SaveMode.Append).insertInto("test1")) |
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.
please fix the typo, should be test21721
instead of test1
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.
Will fix now.
… successfully removed ## What changes were proposed in this pull request? We put staging path to delete into the deleteOnExit cache of `FileSystem` in case of the path can't be successfully removed. But when we successfully remove the path, we don't remove it from the cache. We should do it to avoid continuing grow the cache size. ## How was this patch tested? Added a test. Author: Liang-Chi Hsieh <viirya@gmail.com> Closes apache#18934 from viirya/SPARK-21721. (cherry picked from commit 4c3cf1c) Signed-off-by: gatorsmile <gatorsmile@gmail.com>
What changes were proposed in this pull request?
We put staging path to delete into the deleteOnExit cache of
FileSystem
in case of the path can't be successfully removed. But when we successfully remove the path, we don't remove it from the cache. We should do it to avoid continuing grow the cache size.How was this patch tested?
Added a test.