Skip to content

[SPARK-4764] Ensure that files are fetched atomically #2855

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

Closed
wants to merge 5 commits into from

Conversation

preaudc
Copy link

@preaudc preaudc commented Oct 20, 2014

tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic

tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

1 similar comment
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@andrewor14
Copy link
Contributor

add to whitelist

@SparkQA
Copy link

SparkQA commented Oct 28, 2014

QA tests have started for PR 2855 at commit 8ea871f.

  • This patch does not merge cleanly.

@SparkQA
Copy link

SparkQA commented Oct 28, 2014

QA tests have finished for PR 2855 at commit 8ea871f.

  • This patch passes all tests.
  • This patch does not merge cleanly.
  • This patch adds no public classes.

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22374/
Test PASSed.

@SparkQA
Copy link

SparkQA commented Nov 3, 2014

Test build #22815 has started for PR 2855 at commit 54419ae.

  • This patch merges cleanly.

tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic
@SparkQA
Copy link

SparkQA commented Nov 3, 2014

Test build #22816 has started for PR 2855 at commit 9ba89ca.

  • This patch merges cleanly.

@preaudc
Copy link
Author

preaudc commented Nov 3, 2014

I've just resync my local fork so that the patch merges cleanly (i.e. there are no other modifications compared to the initial patch)

@SparkQA
Copy link

SparkQA commented Nov 3, 2014

Test build #22815 has finished for PR 2855 at commit 54419ae.

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22815/
Test PASSed.

@SparkQA
Copy link

SparkQA commented Nov 3, 2014

Test build #22816 has finished for PR 2855 at commit 9ba89ca.

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/22816/
Test PASSed.

@andrewor14
Copy link
Contributor

Hey @preaudc can you explain how this fixes SPARK-3967?

@andrewor14
Copy link
Contributor

Also, how does this relate to #2848? Can you and @ryan-williams sort out which PR makes more sense?

@ryan-williams
Copy link
Contributor

#2484 seems beneficial no matter what; why would we ever copy a JAR we've just confirmed is identical to the thing already at the destination?

@ryan-williams
Copy link
Contributor

I don't think these two PRs are necessarily that related though, other than each having been borne as a workaround to the same stack-trace. There may be a common root cause but I don't know, so no need to consider them as coupled or mutually exclusive.

@preaudc
Copy link
Author

preaudc commented Nov 7, 2014

As @ryan-williams pointed out, this is initially only a workaround to SPARK-3967.
I have still no idea why the move fails (with a "Permission denied") when the source and target files are not on the same partition (it is no more atomic, but it should succeed anyway).
I have made this patch because it does not seem necessary to download the file into another local directory then move it (it may cause a copy instead of a rename, and does in fact here).

@SparkQA
Copy link

SparkQA commented Nov 19, 2014

Test build #23617 has started for PR 2855 at commit 9ba89ca.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Nov 19, 2014

Test build #23617 has finished for PR 2855 at commit 9ba89ca.

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

@AmplabJenkins
Copy link

Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/23617/
Test FAILed.

@preaudc
Copy link
Author

preaudc commented Nov 21, 2014

I have no clue what could bring this MiMa test failure, and how to fix it. Can anybody give me a hand?

@JoshRosen
Copy link
Contributor

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Dec 1, 2014

Test build #23968 has started for PR 2855 at commit 9ba89ca.

  • This patch merges cleanly.

@SparkQA
Copy link

SparkQA commented Dec 1, 2014

Test build #23968 has finished for PR 2855 at commit 9ba89ca.

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

@AmplabJenkins
Copy link

Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/23968/
Test PASSed.

@JoshRosen
Copy link
Contributor

This looks good to me, since I think that there's no reason to download the temporary file to a different directory than its intended destination. I'd like to be able to merge this independently of #2848, so do you mind creating a new JIRA that describes only this change rather than SPARK-3967 and updating this PR's title to reference that JIRA?

@preaudc preaudc changed the title [SPARK-3967] Ensure that files are fetched atomically [SPARK-4764] Ensure that files are fetched atomically Dec 5, 2014
@preaudc
Copy link
Author

preaudc commented Dec 8, 2014

Thanks for the review, @JoshRosen, I've created a new JIRA as requested.

@JoshRosen
Copy link
Contributor

Thanks for creating the new JIRA. This looks good to me, so I'm going to merge it into master and branch-1.1 for now (I've added a backport-needed label to the JIRA so that we remember to merge this into branch-1.2 after the 1.2.0 vote ends). Thanks!

@asfgit asfgit closed this in ab2abcb Dec 8, 2014
asfgit pushed a commit that referenced this pull request Dec 8, 2014
tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic

Author: Christophe Préaud <christophe.preaud@kelkoo.com>

Closes #2855 from preaudc/master and squashes the following commits:

9ba89ca [Christophe Préaud] Ensure that files are fetched atomically
54419ae [Christophe Préaud] Merge remote-tracking branch 'upstream/master'
c6a5590 [Christophe Préaud] Revert commit 8ea871f
7456a33 [Christophe Préaud] Merge remote-tracking branch 'upstream/master'
8ea871f [Christophe Préaud] Ensure that files are fetched atomically

(cherry picked from commit ab2abcb)
Signed-off-by: Josh Rosen <rosenville@gmail.com>

Conflicts:
	core/src/main/scala/org/apache/spark/util/Utils.scala
asfgit pushed a commit that referenced this pull request Dec 17, 2014
tempFile is created in the same directory than targetFile, so that the
move from tempFile to targetFile is always atomic

Author: Christophe Préaud <christophe.preaud@kelkoo.com>

Closes #2855 from preaudc/master and squashes the following commits:

9ba89ca [Christophe Préaud] Ensure that files are fetched atomically
54419ae [Christophe Préaud] Merge remote-tracking branch 'upstream/master'
c6a5590 [Christophe Préaud] Revert commit 8ea871f
7456a33 [Christophe Préaud] Merge remote-tracking branch 'upstream/master'
8ea871f [Christophe Préaud] Ensure that files are fetched atomically

(cherry picked from commit ab2abcb)
Signed-off-by: Josh Rosen <joshrosen@databricks.com>
@JoshRosen
Copy link
Contributor

I've finished backporting this to branch-1.2.

@@ -425,8 +425,7 @@ private[spark] object Utils extends Logging {
conf: SparkConf,
securityMgr: SecurityManager,
hadoopConf: Configuration) {
val tempDir = getLocalDir(conf)
val tempFile = File.createTempFile("fetchFileTemp", null, new File(tempDir))
val tempFile = File.createTempFile("fetchFileTemp", null, new File(targetDir.getAbsolutePath))
Copy link
Member

Choose a reason for hiding this comment

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

Why need to create a new File here: new File(targetDir.getAbsolutePath)? Can't we use targetDir directly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we probably can just use targetDir directly; I guess I overlooked this when reviewing the patch.

@preaudc
Copy link
Author

preaudc commented Jan 5, 2015

Yes, my bad, targetDir is indeed already a File. @JoshRosen , how could I fix this, should I create a new pull request, or can this one be reopened?

@JoshRosen
Copy link
Contributor

@preaudc We can't re-open this PR, so you'd have to create a new one. This is a really minor issue, though, so I'm not in a huge rush to fix it (it's more of a code-cleanliness issue than a correctness issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants