qubole / sparklens

Qubole Sparklens tool for performance tuning Apache Spark
http://sparklens.qubole.com
Apache License 2.0
566 stars 138 forks source link

QuboleJobListener threw an exception java.lang.NullPointerException #28

Open ayush-chauhan opened 5 years ago

ayush-chauhan commented 5 years ago

Getting this error which leads to my job failure. This exception leads to this error - org.apache.spark.SparkException: Job 33 canceled because SparkContext was shut down

18/11/22 08:47:10 ERROR AsyncEventQueue: Listener QuboleJobListener threw an exception
java.lang.NullPointerException
    at scala.collection.mutable.HashTable$$anon$1.next(HashTable.scala:214)
    at scala.collection.mutable.HashTable$$anon$1.next(HashTable.scala:206)
    at scala.collection.mutable.HashMap$$anon$3.next(HashMap.scala:115)
    at scala.collection.IterableLike$class.head(IterableLike.scala:107)
    at scala.collection.AbstractIterable.head(Iterable.scala:54)
    at scala.collection.TraversableLike$class.last(TraversableLike.scala:431)
    at scala.collection.AbstractTraversable.last(Traversable.scala:104)
    at com.qubole.sparklens.common.AppContext$.getMap(AppContext.scala:100)
    at com.qubole.sparklens.timespan.JobTimeSpan.getMap(JobTimeSpan.scala:91)
    at com.qubole.sparklens.common.AppContext$$anonfun$getMap$1.apply(AppContext.scala:102)
    at com.qubole.sparklens.common.AppContext$$anonfun$getMap$1.apply(AppContext.scala:102)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
    at scala.collection.mutable.HashMap$$anon$1$$anonfun$foreach$2.apply(HashMap.scala:103)
    at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:230)
    at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
    at scala.collection.mutable.HashMap$$anon$1.foreach(HashMap.scala:103)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
    at scala.collection.AbstractSet.scala$collection$SetLike$$super$map(Set.scala:47)
    at scala.collection.SetLike$class.map(SetLike.scala:92)
    at scala.collection.AbstractSet.map(Set.scala:47)
    at com.qubole.sparklens.common.AppContext$.getMap(AppContext.scala:102)
    at com.qubole.sparklens.common.AppContext.toString(AppContext.scala:58)
    at com.qubole.sparklens.QuboleJobListener.dumpData(QuboleJobListener.scala:137)
    at com.qubole.sparklens.QuboleJobListener.onApplicationEnd(QuboleJobListener.scala:167)
    at org.apache.spark.scheduler.SparkListenerBus$class.doPostEvent(SparkListenerBus.scala:57)
    at org.apache.spark.scheduler.AsyncEventQueue.doPostEvent(AsyncEventQueue.scala:37)
    at org.apache.spark.scheduler.AsyncEventQueue.doPostEvent(AsyncEventQueue.scala:37)
    at org.apache.spark.util.ListenerBus$class.postToAll(ListenerBus.scala:91)
    at org.apache.spark.scheduler.AsyncEventQueue.org$apache$spark$scheduler$AsyncEventQueue$$super$postToAll(AsyncEventQueue.scala:92)
    at org.apache.spark.scheduler.AsyncEventQueue$$anonfun$org$apache$spark$scheduler$AsyncEventQueue$$dispatch$1.apply$mcJ$sp(AsyncEventQueue.scala:92)
    at org.apache.spark.scheduler.AsyncEventQueue$$anonfun$org$apache$spark$scheduler$AsyncEventQueue$$dispatch$1.apply(AsyncEventQueue.scala:87)
    at org.apache.spark.scheduler.AsyncEventQueue$$anonfun$org$apache$spark$scheduler$AsyncEventQueue$$dispatch$1.apply(AsyncEventQueue.scala:87)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    at org.apache.spark.scheduler.AsyncEventQueue.org$apache$spark$scheduler$AsyncEventQueue$$dispatch(AsyncEventQueue.scala:87)
    at org.apache.spark.scheduler.AsyncEventQueue$$anon$1$$anonfun$run$1.apply$mcV$sp(AsyncEventQueue.scala:83)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1323)
    at org.apache.spark.scheduler.AsyncEventQueue$$anon$1.run(AsyncEventQueue.scala:82)

This is the command I am using spark-submit --jars /home/hadoop/ayush/sparklens_2.11-0.2.0.jar --conf spark.extraListeners=com.qubole.sparklens.QuboleJobListener --class com.oyo.spark.application.MergeIncrementalData --master yarn --deploy-mode cluster --queue ingestion /home/hadoop/jp/application-0.0.1-SNAPSHOT/application-0.0.1-SNAPSHOT-jar-with-dependencies.jar prod ingestiondb.bookings

iamrohit commented 5 years ago

@ayush-chauhan Sorry to hear that. You can use sparklens in offline mode using the event log history files.

 ./bin/spark-submit --packages qubole:sparklens:0.2.0-s_2.11 
--class com.qubole.sparklens.app.ReporterApp qubole-dummy-arg
/tmp/spark-history/application_1520833877547_0285.lz4 source=history

If it is not too big, can you share the event log file. Will help in understanding the root cause.

ayush-chauhan commented 5 years ago

Sorry, there was some issue with my code. I was using multithreading in my code to merge incremental code in parallel. This issue was fixed after I corrected my code.

I have one question though, why sparklens metrics are not useful in the case of multithreading?

iamrohit commented 5 years ago

@ayush-chauhan The way sparklens works right now if that it computes the time spent in the driver by subtracting the time spent during the jobs processing from the total job duration. With multithreading, it is hard to define the notion of driver time. Also multithreading in driver is usually accompanied by use of fair-scheduler in spark. We don't have the ability to simulate fair-scheduler right now. Short answer is that it becomes lot harder to understand the application as well as simulate it when we add these additional degrees of freedom.