-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-core - [SPARK-4787] - Stop sparkcontext properly if a DAGScheduler init error occurs #3809
Conversation
…cheduler initialization.
Can one of the admins verify this patch? |
new SparkException("DAGScheduler cannot be initialized due to %s".format(e.getMessage)) | ||
case e: Exception => { | ||
stop() | ||
throw |
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.
Style nit: you can use string interpolation instead of String.format, which will allow the new SparkException
to fit on the same line as throw
:
throw new SparkException(s"DAGScheduler cannot be initialized due to ${e.getMessage}")
However, I'd prefer to call the two-argument constructor which takes the cause as second argument, since this will lead to more informative stacktraces:
throw new SparkException("Error while constructing DAGScheduler", e)
Jenkins, this is ok to test. |
Test build #24838 has started for PR 3809 at commit
|
This is a nice fix. Resource leaks when SparkContext's constructor throws exceptions have been a longstanding issue. I first ran across the issue while adding logic to detect whether a SparkContext was already running when attempting to create a new one (SPARK-4180). In that case, I ran into some issues because I wanted to effectively make the entire constructor synchronized on a static object, but this was hard because there wasn't an explicit constructor method. We could have tried to wrap the entire "implicit constructor" in a try-finally block, but this would require us to re-organize a huge amount of code and change many Barring a big restructuring of SparkContext's constructor, though, small fixes like this are welcome. Therefore, this looks good to me. |
By the way, I left a comment over on JIRA about the scope of the SPARK-4787 JIRA. If we merge this PR as-is, without adding more try-catches for other statements that could throw exceptions, then I think we should revise that JIRA to describe only the fix implemented here (error-catching for DAGScheduler errors) and should convert it into a subtask of SPARK-4180. |
Test build #24838 has finished for PR 3809 at commit
|
Test PASSed. |
case e: Exception => throw | ||
new SparkException("DAGScheduler cannot be initialized due to %s".format(e.getMessage)) | ||
case e: Exception => { | ||
stop() |
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.
Also, do you think this should be in a try-finally block so that we don't swallow the useful "DAGScheduler could not be initialized" exception if the stop() call somehow fails?
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.
Excellent idea Josh.
… using a finally block.
Test build #24873 has started for PR 3809 at commit
|
Test build #24873 has finished for PR 3809 at commit
|
Test PASSed. |
Alright, I've re-scoped SPARK-4787 to only cover the changes here and made it into a subtask of the broader SPARK-4194 issue. So as "not to let the perfect be the enemy of the good", I'm going to merge this now and we can address the broader cleanup issues in later PRs. Thanks for the fix! |
Author: Dale <tigerquoll@outlook.com> Closes #3809 from tigerquoll/SPARK-4787 and squashes the following commits: 5661e01 [Dale] [SPARK-4787] Ensure that call to stop() doesn't lose the exception by using a finally block. 2172578 [Dale] [SPARK-4787] Stop context properly if an exception occurs during DAGScheduler initialization. (cherry picked from commit 3fddc94) Signed-off-by: Josh Rosen <joshrosen@databricks.com>
Author: Dale <tigerquoll@outlook.com> Closes #3809 from tigerquoll/SPARK-4787 and squashes the following commits: 5661e01 [Dale] [SPARK-4787] Ensure that call to stop() doesn't lose the exception by using a finally block. 2172578 [Dale] [SPARK-4787] Stop context properly if an exception occurs during DAGScheduler initialization. (cherry picked from commit 3fddc94) Signed-off-by: Josh Rosen <joshrosen@databricks.com>
Author: Dale <tigerquoll@outlook.com> Closes #3809 from tigerquoll/SPARK-4787 and squashes the following commits: 5661e01 [Dale] [SPARK-4787] Ensure that call to stop() doesn't lose the exception by using a finally block. 2172578 [Dale] [SPARK-4787] Stop context properly if an exception occurs during DAGScheduler initialization. (cherry picked from commit 3fddc94) Signed-off-by: Josh Rosen <joshrosen@databricks.com>
Merged into |
[SPARK-4787] Stop SparkContext properly if an exception occurs during DAGscheduler initialization.