Skip to content

[INTERNAL_ERROR] The "collect" action failed. #3949

Closed

Description

@andygrove

Describe the bug

awslabs ran into the following error when testing a recent 0.15.0 snapshot release (0.15.0-preview-1 tag). For some reason, there is no more detail provided in the stack trace, making this difficult to debug.

Execution 'q14b-v4.0' failed: [INTERNAL_ERROR] The "collect" action failed. You hit a bug in Spark or the Spark plugins you use. Please, report this bug to the corresponding communities or vendors, and provide the full stack trace.:
org.apache.spark.SparkException$.internalError(SparkException.scala:107)
org.apache.spark.sql.execution.QueryExecution$.toInternalError(QueryExecution.scala:536)
org.apache.spark.sql.execution.QueryExecution$.withInternalError(QueryExecution.scala:548)
org.apache.spark.sql.Dataset.$anonfun$withAction$1(Dataset.scala:4321)
org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:125)
org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:201)
org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:108)
org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:900)
org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:66)
org.apache.spark.sql.Dataset.withAction(Dataset.scala:4321)
org.apache.spark.sql.Dataset.collect(Dataset.scala:3575)

This issue only happens on specific queries in TPC-DS:

q14a-v4.0
q14b-v4.0
q31-v4.0
q47-v4.0
q57-v4.0

The issue does not happen with 0.14.0 release.

Steps to reproduce

No response

Expected behavior

No response

Additional context

/**
   * Converts asserts, null pointer exceptions to internal errors.
   */
  private[sql] def toInternalError(msg: String, e: Throwable): Throwable = e match {
    case e @ (_: java.lang.NullPointerException | _: java.lang.AssertionError) =>
      SparkException.internalError(
        msg + " You hit a bug in Spark or the Spark plugins you use. Please, report this bug " +
          "to the corresponding communities or vendors, and provide the full stack trace.",
        e)
    case e: Throwable =>
      e
  }

Activity

  1. added
    bug
    on Apr 14, 2026
  2. self-assigned this
    on Apr 14, 2026
  3. added
    priority:high
    and removed on Apr 14, 2026
  4. added this to the 0.15.0 milestone on Apr 14, 2026
  5. andygrove commented on Apr 14, 2026

    @andygrove
    MemberAuthor

    The issue also happens in the 0.14.1-rc1 release.

    In the 0.15.0 snapshot release it happens for scan=auto as well as scan=native_iceberg_compat.

  6. comphead commented on Apr 15, 2026

    @comphead
    Contributor

    Thats frustrating the stacktrace is so short without having a root cause. Is there any steps to reproduce locally?

  7. andygrove commented on Apr 15, 2026

    @andygrove
    MemberAuthor

    I set up spark-sql-perf locally and generated the partitioned 1TB data set and ran q14a-4.0 and cannot reproduce the issue so far

    edit: I am testing single node spark standalone mode with data locally, so not the same as awslabs setup of EKS/S3 and multiple executors

  8. andygrove commented on Apr 15, 2026

    @andygrove
    MemberAuthor

    I forgot to mention earlier that setting spark.comet.dppFallback.enabled=false is a workaround for the issue, but obviously results in poor performance because Comet does not implement DPP yet so will scan all partitions.

    The issue is almost certainly related to the recent PR that changed DPP fallback behavior: #3879

  9. andygrove commented on Apr 15, 2026

    @andygrove
    MemberAuthor

    I am now looking at https://github.com/awslabs/data-on-eks to see if there are clues there to any differences between the way the benchmark is run by awslabs vs the way I am currently running it

  10. andygrove commented on Apr 16, 2026

    @andygrove
    MemberAuthor

    Also worth noting that the root of the plan consists of Spark operators. Comet is accelerating some leaf stages but the collect is reading from Spark operators not Comet.

    == Physical Plan ==
    AdaptiveSparkPlan (603)
    +- == Current Plan ==
       TakeOrderedAndProject (199)
       +- HashAggregate (198)
          +- Exchange (197)
             +- HashAggregate (196)
    
  11. andygrove commented on Apr 16, 2026

    @andygrove
    MemberAuthor

    Looks like the benchmark tool is suppressing the stack trace. Thanks @peter-toth for helping figure that out.

  12. andygrove commented on Apr 16, 2026

    @andygrove
    MemberAuthor

    Stack trace:

    Caused by: java.lang.AssertionError: assertion failed
        at scala.Predef$.assert(Predef.scala:208)
        at org.apache.spark.sql.execution.ColumnarToRowExec.<init>(Columnar.scala:70)
    

    Spark code:

    case class ColumnarToRowExec(child: SparkPlan) extends ColumnarToRowTransition with CodegenSupport {
      // supportsColumnar requires to be only called on driver side, see also SPARK-37779.
      assert(Utils.isInRunningSparkTask || child.supportsColumnar)

    somehow there is a mismatch where there is ColumnarToRowExec wrapping a plan that is not columnar

  13. andygrove commented on Apr 17, 2026

    @andygrove
    MemberAuthor

    i still have not found a way to repro this

  14. andygrove commented on Apr 17, 2026

    @andygrove
    MemberAuthor

    full stack trace:

    Execution 'q14a-v4.0' failed: [INTERNAL_ERROR] The "collect" action failed. You hit a bug in Spark or the Spark plugins you use. Please, report this bug to the corresponding communities or vendors, and provide the full stack trace.:
    org.apache.spark.SparkException: [INTERNAL_ERROR] The "collect" action failed. You hit a bug in Spark or the Spark plugins you use. Please, report this bug to the corresponding communities or vendors, and provide the full stack trace.
        at org.apache.spark.SparkException$.internalError(SparkException.scala:107)
        at org.apache.spark.sql.execution.QueryExecution$.toInternalError(QueryExecution.scala:536)
        at org.apache.spark.sql.execution.QueryExecution$.withInternalError(QueryExecution.scala:548)
        at org.apache.spark.sql.Dataset.$anonfun$withAction$1(Dataset.scala:4321)
        at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:125)
        at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:201)
        at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:108)
        at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:900)
        at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:66)
        at org.apache.spark.sql.Dataset.withAction(Dataset.scala:4321)
        at org.apache.spark.sql.Dataset.collect(Dataset.scala:3575)
        at com.databricks.spark.sql.perf.Query.$anonfun$doBenchmark$10(Query.scala:122)
        at com.databricks.spark.sql.perf.Benchmarkable.measureTimeMs(Benchmarkable.scala:121)
        at com.databricks.spark.sql.perf.Benchmarkable.measureTimeMs$(Benchmarkable.scala:119)
        at com.databricks.spark.sql.perf.Query.measureTimeMs(Query.scala:29)
        at com.databricks.spark.sql.perf.Query.doBenchmark(Query.scala:121)
        at com.databricks.spark.sql.perf.Benchmarkable$$anon$1.run(Benchmarkable.scala:78)
    Caused by: java.lang.AssertionError: assertion failed
        at scala.Predef$.assert(Predef.scala:208)
        at org.apache.spark.sql.execution.ColumnarToRowExec.<init>(Columnar.scala:70)
        at org.apache.spark.sql.execution.ColumnarToRowExec.copy(Columnar.scala:68)
        at org.apache.spark.sql.execution.ColumnarToRowExec.withNewChildInternal(Columnar.scala:213)
        at org.apache.spark.sql.execution.ColumnarToRowExec.withNewChildInternal(Columnar.scala:68)
        at org.apache.spark.sql.catalyst.trees.UnaryLike.withNewChildrenInternal(TreeNode.scala:1230)
        at org.apache.spark.sql.catalyst.trees.UnaryLike.withNewChildrenInternal$(TreeNode.scala:1228)
        at org.apache.spark.sql.execution.ColumnarToRowExec.withNewChildrenInternal(Columnar.scala:68)
        at org.apache.spark.sql.catalyst.trees.TreeNode.$anonfun$withNewChildren$2(TreeNode.scala:339)
        at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(origin.scala:76)
        at org.apache.spark.sql.catalyst.trees.TreeNode.withNewChildren(TreeNode.scala:338)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:603)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.$anonfun$doCanonicalize$1(QueryPlan.scala:585)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:585)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.$anonfun$doCanonicalize$1(QueryPlan.scala:585)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:585)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.$anonfun$doCanonicalize$1(QueryPlan.scala:585)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:585)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.$anonfun$doCanonicalize$1(QueryPlan.scala:585)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:585)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.$anonfun$doCanonicalize$1(QueryPlan.scala:585)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.doCanonicalize(QueryPlan.scala:585)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.execution.exchange.BroadcastExchangeExec.doCanonicalize(BroadcastExchangeExec.scala:98)
        at org.apache.spark.sql.execution.exchange.BroadcastExchangeExec.doCanonicalize(BroadcastExchangeExec.scala:83)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized$lzycompute(QueryPlan.scala:571)
        at org.apache.spark.sql.catalyst.plans.QueryPlan.canonicalized(QueryPlan.scala:570)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.createQueryStages(AdaptiveSparkPlanExec.scala:546)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$createQueryStages$2(AdaptiveSparkPlanExec.scala:580)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.createQueryStages(AdaptiveSparkPlanExec.scala:580)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$createQueryStages$2(AdaptiveSparkPlanExec.scala:580)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.createQueryStages(AdaptiveSparkPlanExec.scala:580)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.createQueryStages(AdaptiveSparkPlanExec.scala:536)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$createQueryStages$2(AdaptiveSparkPlanExec.scala:580)
        at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
        at scala.collection.Iterator.foreach(Iterator.scala:943)
        at scala.collection.Iterator.foreach$(Iterator.scala:943)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
        at scala.collection.IterableLike.foreach(IterableLike.scala:74)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
        at scala.collection.TraversableLike.map(TraversableLike.scala:286)
        at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
        at scala.collection.AbstractTraversable.map(Traversable.scala:108)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.createQueryStages(AdaptiveSparkPlanExec.scala:580)
        at org.apache.spark.sql.execution.adaptive.AdaptiveSparkPlanExec.$anonfun$createQueryStages$2(AdaptiveSparkPlanExec.scala:580)
    
  15. andygrove commented on Apr 17, 2026

    @andygrove
    MemberAuthor

    I think I understand the issue now, and I now have additional logging which seems to confirm.

    Comet planning happens for the initial plan and again during AQE re-planning. If Comet makes different decisions during the different phases of planning then it can lead to mismatches in the plan.

    In the follow log there are two exchanges with fallback reasons, but only one correctly fell back.

       :     +- CometSinkPlaceHolder
       :        +-  CometColumnarExchange [COMET: Stage contains a scan with Dynamic Partition Pruning]
       :           +- HashAggregate
       :              +- AQEShuffleRead
       :                 +-  Exchange [COMET: Stage contains a scan with Dynamic Partition Pruning]
       :                    +- HashAggregate
    
  16. added a commit that references this issue on Apr 17, 2026
  17. comphead commented on Apr 17, 2026

    @comphead
    Contributor

    makes sense as DPP as part of AQE. Why we have CometColumnarExchange? is it because fallbackToColumnar?

  18. andygrove commented on Apr 17, 2026

    @andygrove
    MemberAuthor

    makes sense as DPP as part of AQE. Why we have CometColumnarExchange? is it because fallbackToColumnar?

    During AQE, CometColumnarExchange was chosen because the child plan is not native. The DPP fallback rule did not trigger even though it did trigger when doing the initial planning before AQE started.

  19. andygrove commented on Apr 17, 2026

    @andygrove
    MemberAuthor

    makes sense as DPP as part of AQE. Why we have CometColumnarExchange? is it because fallbackToColumnar?

    During AQE, CometColumnarExchange was chosen because the child plan is not native. The DPP fallback rule did not trigger even though it did trigger when doing the initial planning before AQE started.

    There is no fallbackToColumnar config now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpriority:high

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions