Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

viirya
Copy link
Member

@viirya viirya commented Aug 14, 2017

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.

@SparkQA
Copy link

SparkQA commented Aug 14, 2017

Test build #80609 has finished for PR 18934 at commit 1f8444d.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member Author

viirya commented Aug 14, 2017

There is a test which doesn't drop the table it created...

@viirya viirya force-pushed the SPARK-21721 branch 2 times, most recently from 8912397 to 976e288 Compare August 14, 2017 06:55
@SparkQA
Copy link

SparkQA commented Aug 14, 2017

Test build #80614 has finished for PR 18934 at commit 976e288.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Aug 14, 2017

Test build #80613 has finished for PR 18934 at commit 8912397.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@viirya
Copy link
Member Author

viirya commented Aug 14, 2017

retest this please.

@SparkQA
Copy link

SparkQA commented Aug 14, 2017

Test build #80621 has finished for PR 18934 at commit 976e288.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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)
Copy link
Member

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.

Copy link
Member Author

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") {
Copy link
Member

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?

Copy link
Member Author

@viirya viirya Aug 14, 2017

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK.

@SparkQA
Copy link

SparkQA commented Aug 14, 2017

Test build #80627 has finished for PR 18934 at commit 13defbb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

createdTempDir.foreach { path => path.getFileSystem(hadoopConf).delete(path, true) }
createdTempDir.foreach { path =>
val fs = path.getFileSystem(hadoopConf)
fs.delete(path, true)
Copy link
Contributor

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)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Great. Thanks.

@SparkQA
Copy link

SparkQA commented Aug 15, 2017

Test build #80649 has finished for PR 18934 at commit 2b0fd74.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM.

@gatorsmile
Copy link
Member

LGTM

asfgit pushed a commit that referenced this pull request Aug 15, 2017
… 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>
@gatorsmile
Copy link
Member

Thanks! Merging to master/2.2

@asfgit asfgit closed this in 4c3cf1c Aug 15, 2017
@gatorsmile
Copy link
Member

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!

@yzheng616
Copy link

Please try to fix it in 2.1 too. We have a product running on this version Spark. Thanks a lot!

@gatorsmile
Copy link
Member

cc @viirya

@viirya
Copy link
Member Author

viirya commented Aug 15, 2017

@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"))
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix now.

MatthewRBruce pushed a commit to Shopify/spark that referenced this pull request Jul 31, 2018
… 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>
@viirya viirya deleted the SPARK-21721 branch December 27, 2023 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants