Skip to content

SPARK-3014. Log a more informative messages in a couple failure scenario... #1934

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 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/src/main/scala/org/apache/spark/deploy/SparkSubmit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.spark.deploy

import java.io.{File, PrintStream}
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.{Modifier, InvocationTargetException}
import java.net.URL

import scala.collection.mutable.{ArrayBuffer, HashMap, Map}
Expand Down Expand Up @@ -323,7 +323,9 @@ object SparkSubmit {
}

val mainMethod = mainClass.getMethod("main", new Array[String](0).getClass)

if (!Modifier.isStatic(mainMethod.getModifiers)) {
throw new IllegalStateException("The main method in the given main class must be static")
}
try {
mainMethod.invoke(null, childArgs.toArray)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,9 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments,
}

val sparkContext = sparkContextRef.get()
assert(sparkContext != null || count >= numTries)
if (sparkContext == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove this assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the assertion fails, it's a consequence of user error, not a logic error in Spark's code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, actually misread it. Will add it back in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On third thought, I don't really think the assert is useful. Adding it back in would require adding "|| finished", which basically makes it look exactly the same as the while loop condition above. It doesn't make the code any easier to understand.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. This assertion technically had a chance to fail before, if we haven't incremented count all the way and finished becomes true, and the assertion failure is meaningless.

logError(
"Unable to retrieve sparkContext inspite of waiting for %d, numTries = %d".format(
count * waitTime, numTries))
logError(("SparkContext did not initialize after waiting for %d ms. Please check earlier"
+ " log output for errors. Failing the application.").format(numTries * waitTime))
}
sparkContext
}
Expand Down