GitHub user marmbrus opened a pull request:

    https://github.com/apache/spark/pull/409

    Include stack trace for exceptions thrown by user code.

    It is very confusing when your code throws an exception, but the only stack 
trace show is in the DAGScheduler.  This is a simple patch to include the stack 
trace for the actual failure in the error message.  Suggestions on formatting 
welcome.
    
    Before:
    ```
    scala> sc.parallelize(1 :: Nil).map(_ => sys.error("Ahh!")).collect()
    org.apache.spark.SparkException: Job aborted due to stage failure: Task 
0.0:3 failed 1 times (most recent failure: Exception failure in TID 3 on host 
localhost: java.lang.RuntimeException: Ahh!)
        at 
org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1055)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$org$apache$spark$scheduler$DAGScheduler$$abortStage$1.apply(DAGScheduler.scala:1039)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$org$apache$spark$scheduler$DAGScheduler$$abortStage$1.apply(DAGScheduler.scala:1037)
    ...
    ```
    
    After:
    ```
    org.apache.spark.SparkException: Job aborted due to stage failure: Task 
0.0:3 failed 1 times, most recent failure: Exception failure in TID 3 on host 
localhost: java.lang.RuntimeException: Ahh!
    scala.sys.package$.error(package.scala:27)
    $iwC$$iwC$$iwC$$iwC$$anonfun$1.apply(<console>:13)
    $iwC$$iwC$$iwC$$iwC$$anonfun$1.apply(<console>:13)
    scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
    scala.collection.Iterator$class.foreach(Iterator.scala:727)
    scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
    scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:103)
    scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:47)
    scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)
    scala.collection.AbstractIterator.to(Iterator.scala:1157)
    scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:265)
    scala.collection.AbstractIterator.toBuffer(Iterator.scala:1157)
    scala.collection.TraversableOnce$class.toArray(TraversableOnce.scala:252)
    scala.collection.AbstractIterator.toArray(Iterator.scala:1157)
    org.apache.spark.rdd.RDD$$anonfun$6.apply(RDD.scala:676)
    org.apache.spark.rdd.RDD$$anonfun$6.apply(RDD.scala:676)
    
org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1048)
    
org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:1048)
    org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:110)
    org.apache.spark.scheduler.Task.run(Task.scala:50)
    
org.apache.spark.executor.Executor$TaskRunner$$anonfun$run$1.apply$mcV$sp(Executor.scala:211)
    org.apache.spark.deploy.SparkHadoopUtil.runAsUser(SparkHadoopUtil.scala:46)
    org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:176)
    
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    java.lang.Thread.run(Thread.java:744)
        at 
org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1055)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$org$apache$spark$scheduler$DAGScheduler$$abortStage$1.apply(DAGScheduler.scala:1039)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$org$apache$spark$scheduler$DAGScheduler$$abortStage$1.apply(DAGScheduler.scala:1037)
        at 
scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
        at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
        at 
org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$abortStage(DAGScheduler.scala:1037)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$processEvent$10.apply(DAGScheduler.scala:614)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$processEvent$10.apply(DAGScheduler.scala:614)
        at scala.Option.foreach(Option.scala:236)
        at 
org.apache.spark.scheduler.DAGScheduler.processEvent(DAGScheduler.scala:614)
        at 
org.apache.spark.scheduler.DAGScheduler$$anonfun$start$1$$anon$2$$anonfun$receive$1.applyOrElse(DAGScheduler.scala:143)
        at akka.actor.ActorCell.receiveMessage(ActorCell.scala:498)
        at akka.actor.ActorCell.invoke(ActorCell.scala:456)
        at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:237)
        at akka.dispatch.Mailbox.run(Mailbox.scala:219)
        at 
akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:386)
        at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
        at 
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
        at 
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
        at 
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
    ```

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/marmbrus/spark stacktraces

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/409.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #409
    
----
commit 018b06bb69d41845c7d9e1d3e952f7a5f5b08a74
Author: Michael Armbrust <[email protected]>
Date:   2014-04-15T02:57:55Z

    Include stack trace for exceptions in user code.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to