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-20465][CORE] Throws a proper exception when any temp directory could not be got #17768

Closed

Conversation

HyukjinKwon
Copy link
Member

@HyukjinKwon HyukjinKwon commented Apr 26, 2017

What changes were proposed in this pull request?

This PR proposes to throw an exception with better message rather than ArrayIndexOutOfBoundsException when temp directories could not be created.

Running the commands below:

./bin/spark-shell --conf spark.local.dir=/NONEXISTENT_DIR_ONE,/NONEXISTENT_DIR_TWO

produces ...

Before

Exception in thread "main" java.lang.ExceptionInInitializerError
        ...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        ...

After

Exception in thread "main" java.lang.ExceptionInInitializerError
        ...
Caused by: java.io.IOException: Failed to get a temp directory under [/NONEXISTENT_DIR_ONE,/NONEXISTENT_DIR_TWO].
        ...

How was this patch tested?

Unit tests in LocalDirsSuite.scala.

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76171 has started for PR 17768 at commit b9ce248.

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76172 has started for PR 17768 at commit bf21e3b.

@HyukjinKwon
Copy link
Member Author

This actually also happens when the directory exists but the user does not have the permission.

@HyukjinKwon HyukjinKwon changed the title [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got/created (rather than ArrayIndexOutOfBoundsException) [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got Apr 26, 2017
@HyukjinKwon
Copy link
Member Author

@JoshRosen, could you take a look and see if it makes sense?

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me vs failing with a less clear exception

val message = intercept[IOException] {
Utils.getLocalDir(conf)
}.getMessage
assert(message ===
Copy link
Member

Choose a reason for hiding this comment

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

I would only suggest not testing the exact message here, but it's not a big deal. Maybe testing for the existence of the paths.

@HyukjinKwon
Copy link
Member Author

Thank you @srowen.

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76175 has finished for PR 17768 at commit 0f55c49.

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

@HyukjinKwon
Copy link
Member Author

retest this please

1 similar comment
@HyukjinKwon
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76177 has finished for PR 17768 at commit 0f55c49.

  • This patch fails from timeout after a configured wait of `250m`.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76186 has finished for PR 17768 at commit 0f55c49.

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

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #3679 has finished for PR 17768 at commit 0f55c49.

  • This patch fails from timeout after a configured wait of `250m`.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Apr 26, 2017

Test build #76199 has finished for PR 17768 at commit 0f55c49.

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

@HyukjinKwon HyukjinKwon changed the title [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got [WIP][SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got Apr 26, 2017
@HyukjinKwon
Copy link
Member Author

retest this please

@HyukjinKwon
Copy link
Member Author

HyukjinKwon commented Apr 27, 2017

Current status: I don't know how using

val dirs = Array.empty[Int]
dirs.headOption.getOrElse {
  throw new Exception("")
}

instead of

val dirs = Array.empty[Int]
dirs(0)

could make the tests failed (given the observations above).
In the last commit, I gave a shot it with if-else as below:

val dirs = Array.empty[Int]
if (dirs.nonEmpty) {
  dirs(0)
} else {
  throw new Exception("")
}

in order to make sure logically this should not make other tests flaky.

@HyukjinKwon HyukjinKwon changed the title [WIP][SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got Apr 27, 2017
@SparkQA
Copy link

SparkQA commented Apr 27, 2017

Test build #76213 has finished for PR 17768 at commit b5c9839.

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

@SparkQA
Copy link

SparkQA commented Apr 27, 2017

Test build #76215 has finished for PR 17768 at commit b5c9839.

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

@HyukjinKwon HyukjinKwon changed the title [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got [WIP][SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got Apr 27, 2017
@HyukjinKwon HyukjinKwon changed the title [WIP][SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got [SPARK-20465][CORE] Throws a proper exception when any temp directory could not be got Apr 27, 2017
@HyukjinKwon
Copy link
Member Author

HyukjinKwon commented Apr 27, 2017

It looks we should clean up the cached local dirs after the test. The newly added test sets it empty path and it seems affecting the tests afterwards. I changed it back to the original proposal with the cleanup.

@HyukjinKwon
Copy link
Member Author

retest this please

@SparkQA
Copy link

SparkQA commented Apr 27, 2017

Test build #76225 has finished for PR 17768 at commit 751f161.

  • This patch fails from timeout after a configured wait of `250m`.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Apr 27, 2017

Test build #76231 has finished for PR 17768 at commit 751f161.

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

@asfgit asfgit closed this in 8c911ad Apr 28, 2017
@srowen
Copy link
Member

srowen commented Apr 28, 2017

Merged to master/2.2

asfgit pushed a commit that referenced this pull request Apr 28, 2017
… could not be got

## What changes were proposed in this pull request?

This PR proposes to throw an exception with better message rather than `ArrayIndexOutOfBoundsException` when temp directories could not be created.

Running the commands below:

```bash
./bin/spark-shell --conf spark.local.dir=/NONEXISTENT_DIR_ONE,/NONEXISTENT_DIR_TWO
```

produces ...

**Before**

```
Exception in thread "main" java.lang.ExceptionInInitializerError
        ...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
        ...
```

**After**

```
Exception in thread "main" java.lang.ExceptionInInitializerError
        ...
Caused by: java.io.IOException: Failed to get a temp directory under [/NONEXISTENT_DIR_ONE,/NONEXISTENT_DIR_TWO].
        ...
```

## How was this patch tested?

Unit tests in `LocalDirsSuite.scala`.

Author: hyukjinkwon <gurwls223@gmail.com>

Closes #17768 from HyukjinKwon/throws-temp-dir-exception.

(cherry picked from commit 8c911ad)
Signed-off-by: Sean Owen <sowen@cloudera.com>
@HyukjinKwon HyukjinKwon deleted the throws-temp-dir-exception branch January 2, 2018 03:38
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.

3 participants