-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[SPARK-24243][CORE] Expose exceptions from InProcessAppHandle #21849
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
Conversation
@vanzin could you take a look? I'm not sure if the same race conditions present in the other unit tests apply to the new ones since no |
|
||
assertNotNull(handle.getError()); | ||
assertTrue(handle.getError().isPresent()); | ||
assertTrue(handle.getError().get().getCause() == DUMMY_EXCEPTION); |
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.
assertSame
? (Although it's slightly weird to have a static exception instance being thrown.)
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.
changed to assertSame
@@ -46,6 +47,18 @@ public synchronized void disconnect() { | |||
} | |||
} | |||
|
|||
/** | |||
* Since {@link SparkLauncher} runs {@code spark-submit} in a sub-process, its difficult to |
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.
Since this is a public API, good to follow standard javadoc practices like the first sentence being a short description of the method.
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.
updated the javadocs
* accurately retrieve the full {@link Throwable} from the {@code spark-submit} process. This | ||
* method parses the logs of the sub-process and provides a best-effort attempt at returning | ||
* the last exception thrown by the {@code spark-submit} process. Only the exception message is | ||
* parsed, the associated stack-trace is meaningless. |
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.
lose the dash
@@ -63,6 +71,7 @@ synchronized void start(String appName, Method main, String[] args) { | |||
main.invoke(null, (Object) args); | |||
} catch (Throwable t) { | |||
LOG.log(Level.WARNING, "Application failed with exception.", t); | |||
error = t; |
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.
Might be good to special-case InvocationTargetException
and avoid one level of wrapping which is probably not useful to anyone.
@@ -17,6 +17,8 @@ | |||
|
|||
package org.apache.spark.launcher; | |||
|
|||
import org.apache.commons.lang.StringUtils; |
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.
This module shouldn't really depend on any 3rd-party libraries... there's an oddity in the current parent pom that causes this dependency to be available but I think we should instead fix that by adding this property to launcher/pom.xml:
<hadoop.deps.scope>test</hadoop.deps.scope>
containsIgnoreCase
shouldn't really be hard to replicate. Although, if you really want to simplify things, I'd just set the error in this case to a generic "Spark exited with error code X. Please check logs.".
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.
copied the code into a helper method
ok to test |
Test build #94772 has finished for PR 21849 at commit
|
@vanzin addressed your comments and updated the PR |
Test build #95481 has finished for PR 21849 at commit
|
It's safe to add a mima exception for that error since |
Test build #95488 has finished for PR 21849 at commit
|
Adds a new method to `SparkAppHandle` called `getError` which returns the exception (if present) that caused the underlying Spark app to fail. New tests added to `SparkLauncherSuite` for the new method.
Test build #95489 has finished for PR 21849 at commit
|
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.
Just small things.
* Parses the logs of {@code spark-submit} and returns the last exception thrown. | ||
* | ||
* <p> | ||
* Since {@link SparkLauncher} runs {@code spark-submit} in a sub-process, its difficult to |
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.
it's
also, small nit: keep the text at the same indent level as the p tags (as is done in other classes).
ProblemFilters.exclude[MissingClassProblem]("org.apache.spark.ml.classification.LabelConverter"), | ||
|
||
// [SPARK-24243][CORE] Expose exceptions from InProcessAppHandle | ||
ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.spark.launcher.SparkAppHandle.getError") |
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.
nit: add at the top of the list (then you don't have to touch existing entries).
handle.kill(); | ||
} | ||
restoreSystemProperties(properties); | ||
waitForSparkContextShutdown(); |
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.
This isn't really necessary since ErrorInProcessTestApp
does not create a context; but not a big deal either.
@@ -61,6 +62,10 @@ private void redirect() { | |||
while ((line = reader.readLine()) != null) { | |||
if (active) { | |||
sink.info(line.replaceFirst("\\s*$", "")); | |||
if (error == null && containsIgnoreCase(line, "Error") || containsIgnoreCase(line, |
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.
nit: group the conditions so people don't have to remember how precedence work. Also it looks better if you keep the whole call to containsIgnoreCase
in the same line.
Wouldn't you want to keep the last error, though, instead of the first one?
Adds a new method to SparkAppHandle called getError which returns the exception (if present) that caused the underlying Spark app to fail. New tests added to SparkLauncherSuite for the new method. Closes apache#21849 Closes apache#23221 from vanzin/SPARK-24243. Signed-off-by: Marcelo Vanzin <vanzin@cloudera.com>
What changes were proposed in this pull request?
Adds a new method to
SparkAppHandle
calledgetError
which returnsthe exception (if present) that caused the underlying Spark app to
fail.
How was this patch tested?
New tests added to
SparkLauncherSuite
for the new method.