You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/02 05:18:55 UTC

[GitHub] [spark] cloud-fan commented on a change in pull request #27752: [SPARK-30999][SQL] Don't cancel a QueryStageExec which is already finished

cloud-fan commented on a change in pull request #27752: [SPARK-30999][SQL] Don't cancel a QueryStageExec which is already finished
URL: https://github.com/apache/spark/pull/27752#discussion_r386201254
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/AdaptiveSparkPlanExec.scala
 ##########
 @@ -158,25 +158,34 @@ case class AdaptiveSparkPlanExec(
       var result = createQueryStages(currentPhysicalPlan)
       val events = new LinkedBlockingQueue[StageMaterializationEvent]()
       val errors = new mutable.ArrayBuffer[SparkException]()
+      val runningStages = util.Collections.synchronizedSet(new util.HashSet[QueryStageExec]())
       var stagesToReplace = Seq.empty[QueryStageExec]
       while (!result.allChildStagesMaterialized) {
         currentPhysicalPlan = result.newPlan
         if (result.newStages.nonEmpty) {
           stagesToReplace = result.newStages ++ stagesToReplace
           executionId.foreach(onUpdatePlan)
 
-          // Start materialization of all new stages.
-          result.newStages.foreach { stage =>
+          // Start materialization of all new stages and fail fast if any stages failed eagerly
+          var anyFail = false
+          val stages = result.newStages.toIterator
+          while (!anyFail && stages.hasNext) {
+            val stage = stages.next()
+            runningStages.add(stage)
             try {
               stage.materialize().onComplete { res =>
+                runningStages.remove(stage)
 
 Review comment:
   it's easy to tell if a stage is finished or not, by checking `QueryStageExec.resultOption.isEmpty`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org