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

Benchmark runner improved error handling #1299

Merged
merged 1 commit into from
Dec 8, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ object BenchUtils {
val elapsed = NANOSECONDS.toMillis(end - start)
println(s"*** Iteration $i failed after $elapsed msec.")
queryTimes.append(-1)
exceptions.append(BenchUtils.toString(e))
exceptions.append(BenchUtils.stackTraceAsString(e))
e.printStackTrace()
}
}
Expand Down Expand Up @@ -241,9 +241,19 @@ object BenchUtils {
sparkConf = df.sparkSession.conf.getAll,
getSparkVersion)

// if the query plan is invalid, referencing the `executedPlan` lazy val
// can throw an exception
val executedPlanStr = try {
df.queryExecution.executedPlan.toString()
} catch {
case e: Exception =>
exceptions.append(stackTraceAsString(e))
"Failed to capture executedPlan - see exceptions in report"
}

val queryPlan = QueryPlan(
df.queryExecution.logical.toString(),
df.queryExecution.executedPlan.toString()
executedPlanStr
)

val report = resultsAction match {
Expand Down Expand Up @@ -662,7 +672,7 @@ object BenchUtils {
}
}

def toString(e: Exception): String = {
def stackTraceAsString(e: Throwable): String = {
val sw = new StringWriter()
val w = new PrintWriter(sw)
e.printStackTrace(w)
Expand All @@ -676,12 +686,21 @@ class BenchmarkListener(
exceptions: ListBuffer[String]) extends QueryExecutionListener {

override def onSuccess(funcName: String, qe: QueryExecution, durationNs: Long): Unit = {
queryPlans += toJson(qe.executedPlan)
addQueryPlan(qe)
}

override def onFailure(funcName: String, qe: QueryExecution, exception: Exception): Unit = {
queryPlans += toJson(qe.executedPlan)
exceptions += BenchUtils.toString(exception)
addQueryPlan(qe)
exceptions += BenchUtils.stackTraceAsString(exception)
}

private def addQueryPlan(qe: QueryExecution) = {
try {
queryPlans += toJson(qe.executedPlan)
} catch {
case e: Exception =>
exceptions.append(BenchUtils.stackTraceAsString(e))
}
}

private def toJson(plan: SparkPlan): SparkPlanNode = {
Expand Down