Skip to content

Conversation

@sidedoorleftroad
Copy link
Contributor

What changes were proposed in this pull request?

Use Files.createDirectory() to create local directory instead of File.mkdir() in DiskBlockManager.
Many times, we will see such error log information like "Failed to create local dir in xxxxxx". But there is no clear information indicating why the directory creation failed.
When Files.createDirectory() fails to create a local directory, it can give specific error information for subsequent troubleshooting(also throws IOException).

Why are the changes needed?

Throw clear error message when creating directory fails.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

DiskBlockManagerSuite

@dongjoon-hyun
Copy link
Member

ok to test

if (!newDir.exists() && !newDir.mkdir()) {
throw new IOException(s"Failed to create local dir in $newDir.")
}
Files.createDirectory(newDir.toPath)
Copy link
Member

Choose a reason for hiding this comment

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

This code looks like a regression. Previously, if the directory exists, we don't throw IOException.
Now, this PR will throw FileAlreadyExistsException if the directory exists.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, either exists() -> Files.createDirectory or just Files.createDirectories would do the trick. The side-effect of latter is that it would also create non-existence parent directories.

Copy link
Member

Choose a reason for hiding this comment

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

+1 for @HeartSaVioR 's advice.

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.

Thank you for making a PR, @sidedoorleftroad . However, the code seems to have a regression. Did you test your code in your Spark jobs?

@SparkQA
Copy link

SparkQA commented Jul 6, 2020

Test build #124981 has finished for PR 28997 at commit 2834c30.

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

@sidedoorleftroad
Copy link
Contributor Author

The code has been modified.
Submitting code for the first time is too nervous.
Thanks a lot!
@dongjoon-hyun @HeartSaVioR

Copy link
Contributor

@HeartSaVioR HeartSaVioR left a comment

Choose a reason for hiding this comment

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

LGTM

@SparkQA
Copy link

SparkQA commented Jul 6, 2020

Test build #125048 has finished for PR 28997 at commit d8ffb71.

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

@HeartSaVioR
Copy link
Contributor

@dongjoon-hyun Do you have more items to suggest? The change looks to be simple and straightforward, but want to double-check.

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. Thank you, @sidedoorleftroad , @HeartSaVioR , and @srowen .
Merged to master for Apache Spark 3.1.0.

@dongjoon-hyun
Copy link
Member

Hi, @sidedoorleftroad . Are you Zuo Dao in Apache JIRA?

@sidedoorleftroad
Copy link
Contributor Author

@dongjoon-hyun Yes, I am.

@dongjoon-hyun
Copy link
Member

Good. SPARK-32172 is assigned to you, @sidedoorleftroad . Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants