You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "guixiaowen (via GitHub)" <gi...@apache.org> on 2024/05/16 14:56:50 UTC

[PR] [SPARK-48309][YARN]Stop am retry, in situations where some errors and… [spark]

guixiaowen opened a new pull request, #46620:
URL: https://github.com/apache/spark/pull/46620

   … retries may not be successful
   
   <!--
   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?
   In yarn cluster mode, spark.yarn.maxAppAttempts will be configured. In our production environment, it is configured as 2 If the first execution fails, AM will retry. However, in some scenarios, even attempting a second task may fail.
   
   For example:
   
   org. apache. park. SQL AnalysisException: Table or view not found: test.testxxxx_xxxxx; Line 1 pos 14;
   Project
   +-Unresolved Relationship [bigdata_qa, testxxxxx_xxxxx], [], false
   
   
   
   Other example:
   Caused by: org. apache. hadoop. hdfs. protocol NSQuotaExceededException: The NameSpace quota (directories and files) of directory/tmp/xxx_file/xxxx is exceeded: quota=1000000 file count=1000001
   
   Would it be more appropriate to try capturing these exceptions and stopping retry?
   
   
   ### Why are the changes needed?
   In some scenarios, even attempting a second task may fail.
   
   
   ### Does this PR introduce _any_ user-facing change?
   The user can throw a SparkStopAMRetryException, and the Application Master will catch the exception and stop retry
   
   For examle
   
   val spark = SparkSession
         .builder()
         .appName("Spark SQL basic example")
         .enableHiveSupport()
         .config("spark.some.config.option", "some-value")
         .getOrCreate()
   
       try {
         spark.sql("select * from test.testxxxx_xxxxx;").show
       } catch {
         case e:AnalysisException => throw new SparkStopAMRetryException("this is a test", e)
       } finally {
         spark.stop()
       }
   
    
   
   
   ### 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.
   -->
   
   
   ### 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.
   -->
   


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   While this PR does not include it, in order to leverage the change introduced for `SparkStopAMRetryException` - existing exception handling will need to be changed (to throw `SparkStopAMRetryException` instead of whatever is being thrown now) - which will be a backwardly incompatible change.
   
   
   I am wondering if we can leverage `SparkException.errorClass` instead - since `SparkException` is thrown by Spark ? Return `EXIT_STOP_AM_RETRY` for some specific subset of error classes ?
   
   +CC @MaxGekk in case this idea makes sense !


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #46620:
URL: https://github.com/apache/spark/pull/46620#issuecomment-2323563725

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   > I am wondering if we can leverage `SparkException.errorClass` instead - since `SparkException` is thrown by Spark ? Return `EXIT_STOP_AM_RETRY` for some specific subset of error classes ?
   
   Agree, this can be used to handle existing exception, Maybe it's a good idea to include several highest frequencies error classes in your production environment
   While `SparkStopAMRetryException` can be used to handle error scenarios afterwards this pr
   +CC @LuciferYang 
   


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   > Hi, @guixiaowen I need some time to think about it as it might break some existing workloads.
   > 
   > Meantime, you can
   > 
   > * Update the PR desc for better readability
   > * Update the PR desc according to the latest change
   > * Revise the doc of `spark.yarn.maxAppAttempts`
   
   @yaooqinn  Ok,  Thank you. 


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #46620: [SPARK-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful
URL: https://github.com/apache/spark/pull/46620


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   > > I am wondering if we can leverage `SparkException.errorClass` instead - since `SparkException` is thrown by Spark ? Return `EXIT_STOP_AM_RETRY` for some specific subset of error classes ?
   > 
   > Agree, this can be used to handle existing exception, Maybe it's a good idea to include several highest frequencies error classes in your production environment While `SparkStopAMRetryException` can be used to handle error scenarios afterwards this pr +CC @LuciferYang
   
   @mridulm  @summaryzb  
   
   Thank you both for helping me review this pr.
   
   In fact, I was initially thinking about whether I could use Spark's existing exception classes to achieve reuse.
   
   But if I don't use new exception information, it may not work for me to do this place. Because in the yarn-cluster mode, the application master determines whether a retry is needed based on the current exception information, such as:
   
    e.getCause match {
                 case _: InterruptedException =>
                 case e: SparkUserAppException(exitCode) =>
            ##     e.getMessage container message ("Table or view not found:") or highest frequencies error message
   
   this code is in ApplicationMaster.
   
   
   But if the user throws their own defined exception information,such as:
   
   throw new MyTestExecption("this is a test exception, I want to stop am retry.")
   
   In ApplicationMaster, unable to capture user-defined exception information.
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   Hi, @guixiaowen I need some time to think about it as it might break some existing workloads.
   
   Meantime, you can
   - Update the PR desc for better readability
   - Update the PR desc according to the latest change
   - Revise the doc of `spark.yarn.maxAppAttempts`


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   In the example code, if it throws `SparkUserAppException(18)` instead of `SparkStopAMRetryException `, will it also trigger a retry with this pr?
   
   


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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


##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala:
##########
@@ -746,6 +746,11 @@ private[spark] class ApplicationMaster(
             e.getCause match {
               case _: InterruptedException =>
                 // Reporter thread can interrupt to stop user class
+              case stopAmRetry: SparkStopAMRetryException =>
+                finish(FinalApplicationStatus.FAILED,
+                  ApplicationMaster.EXIT_STOP_AM_RETYR,
+                  "User class threw exception: "
+                    + StringUtils.stringifyException(stopAmRetry.getCause))

Review Comment:
   @yaooqinn  Yes, I changed it.  



-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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

   > In the example code, if it throws `SparkUserAppException(18)` instead of `SparkStopAMRetryException `, will it also trigger a retry with this pr?
   
   @LuciferYang Lu Thank you for review. I
   
   > In the example code, if it throws `SparkUserAppException(18)` instead of `SparkStopAMRetryException `, will it also trigger a retry with this pr?
   
   @LuciferYang  Thank you for your review. I made the modifications as you said. 


-- 
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-48309][YARN]Stop am retry, in situations where some errors and retries may not be successful [spark]

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


##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala:
##########
@@ -746,6 +746,11 @@ private[spark] class ApplicationMaster(
             e.getCause match {
               case _: InterruptedException =>
                 // Reporter thread can interrupt to stop user class
+              case stopAmRetry: SparkStopAMRetryException =>
+                finish(FinalApplicationStatus.FAILED,
+                  ApplicationMaster.EXIT_STOP_AM_RETYR,
+                  "User class threw exception: "
+                    + StringUtils.stringifyException(stopAmRetry.getCause))

Review Comment:
   Avoid NPE?



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