<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386882#M246174</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110108"&gt;@nagababu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are couples of issues reported for similar kind of behaviour i.e&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-34790" target="_self"&gt;SPARK-34790&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-18105" target="_self"&gt;SPARK-18105 ,&lt;/A&gt;&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-32658" target="_self"&gt;SPARK-32658&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the following things:&lt;/P&gt;&lt;P&gt;Step1: Change the compression codec and run the application. For example,&amp;nbsp;&lt;SPAN&gt;spark.io.compression.codec=snappy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step2: If step1 is not resolved then try to set&amp;nbsp;spark.file.transferTo=false and rerun the application.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step3: You can set the following parameter and rerun the application&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--conf spark.sql.adaptive.fetchShuffleBlocksInBatch=false&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step4: If any of the above steps are not resolved your issue then you can set the following parameters true and false and rerun the application.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;spark.network.crypto.enabled=true
spark.authenticate=true
spark.io.encryption.enabled=true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Step5: If any of the above steps are not resolved your issue needs to tune the shuffle operation.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Apr 2024 06:04:08 GMT</pubDate>
    <dc:creator>RangaReddy</dc:creator>
    <dc:date>2024-04-22T06:04:08Z</dc:date>
    <item>
      <title>terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage</title>
      <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386744#M246139</link>
      <description>&lt;P&gt;While executing the spark application in yarn i was facing the following issue twice or thrice a day these days.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;ERROR MicroBatchExecution:91 - Query [id = 0ec965b7-5dda-43be-940c-3ec8672bcd5c, runId = 17c15719-ab20-4488-ba37-ccf6a6ca27e1] terminated with error&lt;/DIV&gt;&lt;DIV&gt;org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage 185575 (start at DeviceLocationDataListener.scala:148) has failed the maximum allowable number of times: 4. Most recent failure reason: org.apache.spark.shuffle.FetchFailedException: Stream is corrupted&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.storage.ShuffleBlockFetcherIterator.throwFetchFailedException(ShuffleBlockFetcherIterator.scala:554)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.storage.ShuffleBlockFetcherIterator.next(ShuffleBlockFetcherIterator.scala:470)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.storage.ShuffleBlockFetcherIterator.next(ShuffleBlockFetcherIterator.scala:64)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.Iterator$$anon$12.nextCur(Iterator.scala:435) at scala.collection.Iterator$$anon$12.hasNext(Iterator.scala:441)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:409) at org.apache.spark.util.CompletionIterator.hasNext(CompletionIterator.scala:31)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.InterruptibleIterator.hasNext(InterruptibleIterator.scala:37) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:409)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage2.agg_doAggregateWithKeys_0$(generated.java:184)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage2.processNext(generated.java:206)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.sql.execution.WholeStageCodegenExec$$anonfun$13$$anon$1.hasNext(WholeStageCodegenExec.scala:636)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:409) at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:409)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.Iterator$$anon$11.hasNext(Iterator.scala:409) at scala.collection.Iterator$class.isEmpty(Iterator.scala:331)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.AbstractIterator.isEmpty(Iterator.scala:1334) at scala.collection.TraversableOnce$class.nonEmpty(TraversableOnce.scala:111)&lt;/DIV&gt;&lt;DIV&gt;at scala.collection.AbstractIterator.nonEmpty(Iterator.scala:1334) at com.mongodb.spark.MongoSpark$$anonfun$save$1.apply(MongoSpark.scala:117)&lt;/DIV&gt;&lt;DIV&gt;at com.mongodb.spark.MongoSpark$$anonfun$save$1.apply(MongoSpark.scala:117) at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$28.apply(RDD.scala:935)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.rdd.RDD$$anonfun$foreachPartition$1$$anonfun$apply$28.apply(RDD.scala:935) at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2101)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.SparkContext$$anonfun$runJob$5.apply(SparkContext.scala:2101) at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:90)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.scheduler.Task.run(Task.scala:123) at org.apache.spark.executor.Executor$TaskRunner$$anonfun$10.apply(Executor.scala:408)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360) at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:414)&lt;/DIV&gt;&lt;DIV&gt;at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)&lt;/DIV&gt;&lt;DIV&gt;at java.lang.Thread.run(Thread.java:748)&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Caused by: java.io.IOException: Stream is corrupted at net.jpountz.lz4.LZ4BlockInputStream.refill(LZ4BlockInputStream.java:202)&lt;/DIV&gt;&lt;DIV&gt;at net.jpountz.lz4.LZ4BlockInputStream.read(LZ4BlockInputStream.java:157) at net.jpountz.lz4.LZ4BlockInputStream.read(LZ4BlockInputStream.java:170)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.util.Utils$$anonfun$copyStream$1.apply$mcJ$sp(Utils.scala:361) at org.apache.spark.util.Utils$$anonfun$copyStream$1.apply(Utils.scala:348)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.util.Utils$$anonfun$copyStream$1.apply(Utils.scala:348) at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1360)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.util.Utils$.copyStream(Utils.scala:369)&lt;/DIV&gt;&lt;DIV&gt;at org.apache.spark.storage.ShuffleBlockFetcherIterator.next(ShuffleBlockFetcherIterator.scala:462) ... 32 more&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1889)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1877)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I suppose, i was casused when executing the following code:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;df.writeStream
  .foreachBatch { (batchDF: DataFrame, batchId: Long) =&amp;gt;
    batchDF.persist()
    
------mongo insert 1---------
------mongo insert 2---------

batchDF
  .select(DeviceIOIDS.TENANTGROUPUID.value, DeviceIOIDS.WORKERID.value, DeviceIOIDS.TASKUID.value)
  .groupBy(DeviceIOIDS.TENANTGROUPUID.value, DeviceIOIDS.WORKERID.value, DeviceIOIDS.TASKUID.value)
  .count()
  .withColumnRenamed("count", "recordcount")
  .withColumn(DeviceIOIDS.ISTRANSFERRED.value, lit(0))
  .withColumn(DeviceIOIDS.INSERTDATETIME.value, current_timestamp())
  .withColumn(DeviceIOIDS.INSERTDATE.value, current_date())
  .write
  .mode("Append")
  .mongo(
    WriteConfig(
      "mongo.dbname".getConfigValue,
      "mongo.devicelocationtransferredstatus".getConfigValue
    )
  )

batchDF.unpersist()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks for the help&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 10:40:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386744#M246139</guid>
      <dc:creator>nagababu</dc:creator>
      <dc:date>2024-04-18T10:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage</title>
      <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386790#M246151</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110108"&gt;@nagababu&lt;/a&gt;,&amp;nbsp;Welcome to our community! To help you get the best possible answer, I have tagged in our Spark experts&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78612"&gt;@RangaReddy&lt;/a&gt;&amp;nbsp;&amp;nbsp;who may be able to assist you further.&lt;BR /&gt;&lt;BR /&gt;Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 05:11:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386790#M246151</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2024-04-19T05:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage</title>
      <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386882#M246174</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110108"&gt;@nagababu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are couples of issues reported for similar kind of behaviour i.e&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-34790" target="_self"&gt;SPARK-34790&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-18105" target="_self"&gt;SPARK-18105 ,&lt;/A&gt;&amp;nbsp;&lt;A href="https://issues.apache.org/jira/browse/SPARK-32658" target="_self"&gt;SPARK-32658&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the following things:&lt;/P&gt;&lt;P&gt;Step1: Change the compression codec and run the application. For example,&amp;nbsp;&lt;SPAN&gt;spark.io.compression.codec=snappy&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step2: If step1 is not resolved then try to set&amp;nbsp;spark.file.transferTo=false and rerun the application.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step3: You can set the following parameter and rerun the application&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;--conf spark.sql.adaptive.fetchShuffleBlocksInBatch=false&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Step4: If any of the above steps are not resolved your issue then you can set the following parameters true and false and rerun the application.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;spark.network.crypto.enabled=true
spark.authenticate=true
spark.io.encryption.enabled=true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Step5: If any of the above steps are not resolved your issue needs to tune the shuffle operation.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 06:04:08 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/386882#M246174</guid>
      <dc:creator>RangaReddy</dc:creator>
      <dc:date>2024-04-22T06:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage</title>
      <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/387318#M246295</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/110108"&gt;@nagababu&lt;/a&gt;,&amp;nbsp;Did the response assist in resolving your query? If it did, kindly mark the relevant reply as the solution, as it will aid others in locating the answer more easily in the future.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Apr 2024 06:31:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/387318#M246295</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2024-04-29T06:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: terminated with error org.apache.spark.SparkException: Job aborted due to stage failure: ResultStage</title>
      <link>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/389318#M246951</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/78612"&gt;@RangaReddy&lt;/a&gt; , thank you very much for your response and suggestions. I tried the steps you recommended, and while they were helpful, I found that the issue was ultimately resolved by increasing the executor memory and by setting the spark.file.transferTo=false.&lt;/P&gt;&lt;P&gt;I appreciate your assistance.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 05:12:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/terminated-with-error-org-apache-spark-SparkException-Job/m-p/389318#M246951</guid>
      <dc:creator>nagababu</dc:creator>
      <dc:date>2024-06-18T05:12:30Z</dc:date>
    </item>
  </channel>
</rss>

