You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "jingz-db (via GitHub)" <gi...@apache.org> on 2024/08/20 22:04:55 UTC
[PR] classify foreach user error [spark]
jingz-db opened a new pull request, #47819:
URL: https://github.com/apache/spark/pull/47819
<!--
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.
-->
### 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.
-->
### 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'.
-->
### 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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR closed pull request #47819: [SPARK-49326][SS] Classify Error class for Foreach sink user function error
URL: https://github.com/apache/spark/pull/47819
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1746229155
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +164,23 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val sparkEx = ExecutorDeadException("network error")
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw sparkEx
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getCause.asInstanceOf[ExecutorDeadException].getMessage
Review Comment:
Ah OK, that's good. Thanks for the explanation.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1731643370
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
+ assert(e.getCause.getMessage.contains("ForeachSinkSuite error"))
Review Comment:
Changed the assertion to check for both message and exception type.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1731642856
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
Review Comment:
Thanks for your review! I am afraid we cannot use checkError here as the errorClass that e returns is `STREAM_FAILED` and the `FOREACH_USER_FUNCTION_ERROR` was thrown as part of the message instead of cause [here](https://github.com/apache/spark/pull/45449/files#diff-7e8a99d76adb60a2d85609ab46bb2867cd83de106b3c048d6d955805824c9bb6R335) .
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1746193606
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
Review Comment:
Yeah, it is following the style that Micheal did in this PR: https://github.com/apache/spark/pull/45299
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1746189623
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +164,23 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val sparkEx = ExecutorDeadException("network error")
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw sparkEx
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getCause.asInstanceOf[ExecutorDeadException].getMessage
Review Comment:
The stack trace for `e2` is:
```
org.apache.spark.sql.streaming.StreamingQueryException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 13) (ip-10-110-191-161.us-west-2.compute.internal executor driver): org.apache.spark.ExecutorDeadException: [INTERNAL_ERROR_NETWORK] network error SQLSTATE: XX000
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15(ForeachWriterSuite.scala:168)
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15$adapted(ForeachWriterSuite.scala:129)
...
```
And `e2.getCause` is:
```
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 13) (ip-10-110-191-161.us-west-2.compute.internal executor driver): org.apache.spark.ExecutorDeadException: [INTERNAL_ERROR_NETWORK] network error SQLSTATE: XX000
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15(ForeachWriterSuite.scala:168)
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15$adapted(ForeachWriterSuite.scala:129)
...
```
Looks like before my change, all forEach exception will already have this extra one level of `SparkException`: https://github.com/apache/spark/pull/47819/files#diff-6ed6f67f5a52591e4293b31b509c6c3a9007070ddd4a89e4907a2c9865ca1970L146. So this behavior is preserved in my change.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1744980379
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +164,23 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val sparkEx = ExecutorDeadException("network error")
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw sparkEx
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getCause.asInstanceOf[ExecutorDeadException].getMessage
Review Comment:
Could you please paste the exception hierarchy here? I wonder why this needs one more level to go through.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1744964501
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
Review Comment:
But I guess we should be still able to figure out error class from cause, right? Otherwise how we could leverage the new error class we added in this fix?
e.cause should be wrapped exception having `FOREACH_USER_FUNCTION_ERROR` error class. Otherwise we'll need to revisit whether the error class will be captured in termination event in streaming query listener.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1735270391
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +144,13 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
+ assert(e.cause.asInstanceOf[RuntimeException].getMessage == funcEx.getMessage)
Review Comment:
Ah somehow exact equal will fail... Not sure why though.
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on PR #47819:
URL: https://github.com/apache/spark/pull/47819#issuecomment-2332751207
Thanks! 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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "micheal-o (via GitHub)" <gi...@apache.org>.
micheal-o commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1725936402
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
Review Comment:
you can use `checkError()` func
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +161,21 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw ExecutorDeadException("network error")
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getMessage.contains("network error"))
Review Comment:
also check causing ex type
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
+ assert(e.getCause.getMessage.contains("ForeachSinkSuite error"))
Review Comment:
lets also assert the causing error is the expected exception type
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "micheal-o (via GitHub)" <gi...@apache.org>.
micheal-o commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1732154471
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +164,23 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val sparkEx = ExecutorDeadException("network error")
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw sparkEx
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getCause.asInstanceOf[ExecutorDeadException].getMessage
+ == sparkEx.getMessage)
Review Comment:
ditto
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +144,13 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
+ assert(e.cause.asInstanceOf[RuntimeException].getMessage == funcEx.getMessage)
Review Comment:
can just compare the object i.e. `e.cause == funcEx` ?
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "jingz-db (via GitHub)" <gi...@apache.org>.
jingz-db commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1746189623
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -157,6 +164,23 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
assert(errorEvent.error.get.getMessage === "ForeachSinkSuite error")
// 'close' shouldn't be called with abort message if close with error has been called
assert(allEvents(0).size == 3)
+
+ val sparkEx = ExecutorDeadException("network error")
+ val e2 = intercept[StreamingQueryException] {
+ val query2 = input.toDS().repartition(1).writeStream
+ .foreach(new TestForeachWriter() {
+ override def process(value: Int): Unit = {
+ super.process(value)
+ throw sparkEx
+ }
+ }).start()
+ query2.processAllAvailable()
+ }
+
+ // we didn't wrap the spark exception
+ assert(!e2.getMessage.contains(errClass))
+ assert(e2.getCause.getCause.asInstanceOf[ExecutorDeadException].getMessage
Review Comment:
The stack trace for `e2` is:
```
org.apache.spark.sql.streaming.StreamingQueryException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 13) (ip-10-110-191-161.us-west-2.compute.internal executor driver): org.apache.spark.ExecutorDeadException: [INTERNAL_ERROR_NETWORK] network error SQLSTATE: XX000
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15(ForeachWriterSuite.scala:168)
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15$adapted(ForeachWriterSuite.scala:129)
...
```
And `e2.getCause` is:
```
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 11.0 failed 1 times, most recent failure: Lost task 0.0 in stage 11.0 (TID 13) (ip-10-110-191-161.us-west-2.compute.internal executor driver): org.apache.spark.ExecutorDeadException: [INTERNAL_ERROR_NETWORK] network error SQLSTATE: XX000
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15(ForeachWriterSuite.scala:168)
at org.apache.spark.sql.execution.streaming.sources.ForeachWriterSuite.$anonfun$new$15$adapted(ForeachWriterSuite.scala:129)
...
```
Looks like before my change, all forEach exception will already have this extra one level of `SparkException`: https://github.com/apache/spark/pull/47819/files#diff-6ed6f67f5a52591e4293b31b509c6c3a9007070ddd4a89e4907a2c9865ca1970L146
--
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-49326][SS] Classify Error class for Foreach sink user function error [spark]
Posted by "HeartSaVioR (via GitHub)" <gi...@apache.org>.
HeartSaVioR commented on code in PR #47819:
URL: https://github.com/apache/spark/pull/47819#discussion_r1744971429
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala:
##########
@@ -142,8 +142,12 @@ class ForeachWriterSuite extends StreamTest with SharedSparkSession with BeforeA
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
- assert(e.getCause.isInstanceOf[SparkException])
- assert(e.getCause.getCause.getMessage === "ForeachSinkSuite error")
+
+ val errClass = "FOREACH_USER_FUNCTION_ERROR"
+
+ // verify that we classified the exception
+ assert(e.getMessage.contains(errClass))
Review Comment:
Now I just remembered. We didn't add more element into exception stack when dealing with ForeachBatchUserFuncException, and you're following this. Got 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