You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2024/01/30 15:03:49 UTC

[PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

cloud-fan opened a new pull request, #44953:
URL: https://github.com/apache/spark/pull/44953

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'common/utils/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   This PR fixes two issues when dealing with runtime user errors:
   - Recognize the runtime user errors (mostly ANSI errors) and do not retry tasks for them as it won't help.
   - Throw well-defined errors (the errors with an error class) directly instead of treating it as the cause of the "job aborted" error.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Avoid meaningless task retry and report errors better.
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   Yes, now users can see the actual error directly instead of looking for the cause of "job aborted" error.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   new test
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   No


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471568155


##########
core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala:
##########
@@ -2895,7 +2901,7 @@ private[spark] class DAGScheduler(
   /** Fails a job and all stages that are only used by that job, and cleans up relevant state. */
   private def failJobAndIndependentStages(
       job: ActiveJob,
-      error: SparkException): Unit = {
+      error: Exception): Unit = {

Review Comment:
   ~Is this inevitable?~ Nvm. I found the reason.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1473070577


##########
common/utils/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -74,6 +74,26 @@ private[spark] object SparkThrowableHelper {
     errorClass.startsWith("INTERNAL_ERROR")
   }
 
+  def isRuntimeUserError(e: Throwable): Boolean = {

Review Comment:
   Aren't retriable/transient errors in the minority? Shouldn't we flag those instead?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #44953: [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors
URL: https://github.com/apache/spark/pull/44953


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1475465033


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala:
##########
@@ -322,4 +329,71 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
         "columnName" -> "`col`")
     )
   }
+
+  test("user-facing runtime errors") {

Review Comment:
   nit (if you need to push some changes)
   
   ```suggestion
     test("SPARK-46922: user-facing runtime errors") {
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #44953:
URL: https://github.com/apache/spark/pull/44953#issuecomment-1932057249

   thanks for the review, merging to master!


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "superdupershant (via GitHub)" <gi...@apache.org>.
superdupershant commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471739687


##########
common/utils/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -74,6 +74,26 @@ private[spark] object SparkThrowableHelper {
     errorClass.startsWith("INTERNAL_ERROR")
   }
 
+  def isRuntimeUserError(e: Throwable): Boolean = {

Review Comment:
   I don't know if "UserError" is right concept here. These are more so Data Dependent errors. I think all exceptions with an error class are user facing.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471611997


##########
common/utils/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -74,6 +74,26 @@ private[spark] object SparkThrowableHelper {
     errorClass.startsWith("INTERNAL_ERROR")
   }
 
+  def isRuntimeUserError(e: Throwable): Boolean = {
+    e match {
+      case st: SparkThrowable if st.getErrorClass != null =>
+        st.getErrorClass match {
+          case "DIVIDE_BY_ZERO" | "INTERVAL_DIVIDED_BY_ZERO" => true
+          case "ARITHMETIC_OVERFLOW" | "BINARY_ARITHMETIC_OVERFLOW" | "CAST_OVERFLOW" |
+               "CAST_OVERFLOW_IN_TABLE_INSERT" | "DATETIME_OVERFLOW" |
+               "INTERVAL_ARITHMETIC_OVERFLOW" => true
+          case "CAST_INVALID_INPUT" | "NUMERIC_VALUE_OUT_OF_RANGE" | "CANNOT_PARSE_TIMESTAMP" =>
+            true
+          case "INVALID_ARRAY_INDEX" | "INVALID_ARRAY_INDEX_IN_ELEMENT_AT" |
+               "INVALID_INDEX_OF_ZERO" => true
+          // TODO: add more user-facing runtime errors (mostly ANSI errors).

Review Comment:
   How about to create a `Map`, and to check the given error class in it. Code will be more maintainable and faster.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1475465792


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala:
##########
@@ -322,4 +329,71 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
         "columnName" -> "`col`")
     )
   }
+
+  test("user-facing runtime errors") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      var numTaskStarted = 0
+      val listener = new SparkListener {
+        override def onTaskStart(taskStart: SparkListenerTaskStart): Unit = {
+          numTaskStarted += 1
+        }
+      }
+      sparkContext.addSparkListener(listener)
+      try {
+        val df1 = spark.range(0, 10, 1, 1).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        // If error is not user-facing, it will be wrapped by `SparkException` with "Job aborted".
+        val e1 = intercept[SparkException](df1.collect())
+        assert(e1.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times.
+        assert(numTaskStarted == 2)
+        numTaskStarted = 0
+
+        val df2 = spark.range(0, 10, 1, 2).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        val e2 = intercept[SparkException](df2.collect())
+        assert(e2.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times, the input data has 2 partitions, but
+        // only the first task will fail (contains value 0), so in total 3 tasks started.
+        assert(numTaskStarted == 3)
+        numTaskStarted = 0
+
+        val df3 = spark.range(0, 10, 1, 1).select(lit(1) / $"id")
+        checkError(
+          // If error is user-facing, it will be thrown directly.
+          exception = intercept[SparkArithmeticException](df3.collect()),
+          errorClass = "DIVIDE_BY_ZERO",
+          parameters = Map("config" -> ansiConf),
+          context = ExpectedContext(
+            fragment = "div",
+            callSitePattern = getCurrentClassCallSitePattern
+          )
+        )
+        sparkContext.listenerBus.waitUntilEmpty()
+        // TODO: Spark should not re-try this error.
+        assert(numTaskStarted == 2)
+        numTaskStarted = 0
+
+        val df4 = spark.range(0, 10, 1, 2).select(lit(1) / $"id")
+        checkError(
+          exception = intercept[SparkArithmeticException](df4.collect()),
+          errorClass = "DIVIDE_BY_ZERO",
+          parameters = Map("config" -> ansiConf),
+          context = ExpectedContext(
+            fragment = "div",
+            callSitePattern = getCurrentClassCallSitePattern
+          )
+        )
+        sparkContext.listenerBus.waitUntilEmpty()
+        // TODO: Spark should not re-try tasks this error.

Review Comment:
   nit but should ideally file a JIRA for this e.g., `TODO(SPARK-XXXXX): ...`



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1473751219


##########
common/utils/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -74,6 +74,26 @@ private[spark] object SparkThrowableHelper {
     errorClass.startsWith("INTERNAL_ERROR")
   }
 
+  def isRuntimeUserError(e: Throwable): Boolean = {

Review Comment:
   Ideally I agree with you, but the current behavior is to retry all errors, and I'm afraid of introducing regressions by not retrying most of the errors, as it's hard to identify all the errors that need retry.



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1475468317


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala:
##########
@@ -322,4 +329,71 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
         "columnName" -> "`col`")
     )
   }
+
+  test("SPARK-46922: user-facing runtime errors") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      var numTaskStarted = 0
+      val listener = new SparkListener {
+        override def onTaskStart(taskStart: SparkListenerTaskStart): Unit = {
+          numTaskStarted += 1
+        }
+      }
+      sparkContext.addSparkListener(listener)
+      try {
+        val df1 = spark.range(0, 10, 1, 1).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        // If error is not user-facing, it will be wrapped by `SparkException` with "Job aborted".
+        val e1 = intercept[SparkException](df1.collect())
+        assert(e1.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times.
+        assert(numTaskStarted == 2)
+        numTaskStarted = 0
+
+        val df2 = spark.range(0, 10, 1, 2).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        val e2 = intercept[SparkException](df2.collect())
+        assert(e2.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times, the input data has 2 partitions, but
+        // only the first task will fail (contains value 0), so in total 3 tasks started.
+        assert(numTaskStarted == 3)
+        numTaskStarted = 0
+
+        val df3 = spark.range(0, 10, 1, 1).select(lit(1) / $"id")
+        checkError(
+          // If error is user-facing, it will be thrown directly.
+          exception = intercept[SparkArithmeticException](df3.collect()),
+          errorClass = "DIVIDE_BY_ZERO",
+          parameters = Map("config" -> ansiConf),
+          context = ExpectedContext(
+            fragment = "div",
+            callSitePattern = getCurrentClassCallSitePattern
+          )
+        )
+        sparkContext.listenerBus.waitUntilEmpty()
+        // TODO: Spark should not re-try this error.
+        assert(numTaskStarted == 2)
+        numTaskStarted = 0
+
+        val df4 = spark.range(0, 10, 1, 2).select(lit(1) / $"id")
+        checkError(
+          exception = intercept[SparkArithmeticException](df4.collect()),
+          errorClass = "DIVIDE_BY_ZERO",
+          parameters = Map("config" -> ansiConf),
+          context = ExpectedContext(
+            fragment = "div",
+            callSitePattern = getCurrentClassCallSitePattern
+          )
+        )
+        sparkContext.listenerBus.waitUntilEmpty()
+        // TODO: Spark should not re-try tasks this error.

Review Comment:
   ```suggestion
           // TODO (SPARK-46951): Spark should not re-try tasks for this error.
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "superdupershant (via GitHub)" <gi...@apache.org>.
superdupershant commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471748940


##########
core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala:
##########
@@ -2831,10 +2831,16 @@ private[spark] class DAGScheduler(
     failedStage.latestInfo.completionTime = Some(clock.getTimeMillis())
     updateStageInfoForPushBasedShuffle(failedStage)
     for (job <- dependentJobs) {
-      failJobAndIndependentStages(
-        job,
+      val finalException = exception.collect {
+        // If the error is well defined (has an error class and is not internal error), we treat
+        // it as user-facing, and expose this error to the end users directly.

Review Comment:
   This includes more exception types than just those that match isRuntimeUserError() right? I think we might want a different name somewhere, people might get user-facing error and user error mixed up?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471568155


##########
core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala:
##########
@@ -2895,7 +2901,7 @@ private[spark] class DAGScheduler(
   /** Fails a job and all stages that are only used by that job, and cleans up relevant state. */
   private def failJobAndIndependentStages(
       job: ActiveJob,
-      error: SparkException): Unit = {
+      error: Exception): Unit = {

Review Comment:
   Is this inevitable?



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1475468233


##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryExecutionAnsiErrorsSuite.scala:
##########
@@ -322,4 +329,71 @@ class QueryExecutionAnsiErrorsSuite extends QueryTest
         "columnName" -> "`col`")
     )
   }
+
+  test("SPARK-46922: user-facing runtime errors") {
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
+      var numTaskStarted = 0
+      val listener = new SparkListener {
+        override def onTaskStart(taskStart: SparkListenerTaskStart): Unit = {
+          numTaskStarted += 1
+        }
+      }
+      sparkContext.addSparkListener(listener)
+      try {
+        val df1 = spark.range(0, 10, 1, 1).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        // If error is not user-facing, it will be wrapped by `SparkException` with "Job aborted".
+        val e1 = intercept[SparkException](df1.collect())
+        assert(e1.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times.
+        assert(numTaskStarted == 2)
+        numTaskStarted = 0
+
+        val df2 = spark.range(0, 10, 1, 2).map { v =>
+          if (v > 5) throw new RuntimeException("test error") else v
+        }
+        val e2 = intercept[SparkException](df2.collect())
+        assert(e2.getMessage.contains("Job aborted"))
+        sparkContext.listenerBus.waitUntilEmpty()
+        // In this test suite, Spark re-tries the task 2 times, the input data has 2 partitions, but
+        // only the first task will fail (contains value 0), so in total 3 tasks started.
+        assert(numTaskStarted == 3)
+        numTaskStarted = 0
+
+        val df3 = spark.range(0, 10, 1, 1).select(lit(1) / $"id")
+        checkError(
+          // If error is user-facing, it will be thrown directly.
+          exception = intercept[SparkArithmeticException](df3.collect()),
+          errorClass = "DIVIDE_BY_ZERO",
+          parameters = Map("config" -> ansiConf),
+          context = ExpectedContext(
+            fragment = "div",
+            callSitePattern = getCurrentClassCallSitePattern
+          )
+        )
+        sparkContext.listenerBus.waitUntilEmpty()
+        // TODO: Spark should not re-try this error.

Review Comment:
   ```suggestion
           // TODO (SPARK-46951): Spark should not re-try tasks for this error.
   ```



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Do not wrap runtime user-facing errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #44953:
URL: https://github.com/apache/spark/pull/44953#issuecomment-1922722902

   UPDATE: I removed the task retry part, as I need to investigate more about which errors should be retried. Now this PR only contains the unwrap error part.


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "superdupershant (via GitHub)" <gi...@apache.org>.
superdupershant commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471749722


##########
core/src/main/scala/org/apache/spark/scheduler/TaskSetManager.scala:
##########
@@ -976,6 +976,14 @@ private[spark] class TaskSetManager(
             info.id, taskSet.id, tid, ef.description))
           return
         }
+        if (ef.exception.exists(SparkThrowableHelper.isRuntimeUserError)) {

Review Comment:
   This will be incredibly helpful! 



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #44953:
URL: https://github.com/apache/spark/pull/44953#issuecomment-1917089267

   cc @MaxGekk @srielau @dongjoon-hyun 


-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [SPARK-46922][CORE][SQL] Better handling for runtime user errors [spark]

Posted by "srielau (via GitHub)" <gi...@apache.org>.
srielau commented on code in PR #44953:
URL: https://github.com/apache/spark/pull/44953#discussion_r1471513685


##########
common/utils/src/main/scala/org/apache/spark/SparkThrowableHelper.scala:
##########
@@ -74,6 +74,26 @@ private[spark] object SparkThrowableHelper {
     errorClass.startsWith("INTERNAL_ERROR")
   }
 
+  def isRuntimeUserError(e: Throwable): Boolean = {

Review Comment:
   Would it make sense that this as an optional field to error-classes.json?
   



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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