spark-test commented on code in PR #60454:
URL: https://github.com/apache/spark/pull/60454#discussion_r4569731664
##########
sql/connect/server/src/main/scala/org/apache/spark/sql/connect/utils/ErrorUtils.scala:
##########
@@ -355,6 +355,10 @@ private[connect] object ErrorUtils extends Logging {
case e: Throwable if e.isInstanceOf[SparkThrowable] || NonFatal.apply(e)
=>
StatusProto.toStatusRuntimeException(buildStatusFromThrowable(e,
sessionHolderOpt))
+ // Linkage errors are excluded by NonFatal but still need structured JVM
error details.
+ case e: LinkageError =>
Review Comment:
**Non-blocking (P2):** Linkage errors raised during plan decompression never
reach this case. `RequestDecompressionInterceptor.scala` (lines 86-99) catches
only `case NonFatal(e)` before it calls `ErrorUtils.handleError`, and
`NonFatal` excludes `LinkageError`. So when decompressing a compressed
ExecutePlan or AnalyzePlan request fails with, for example, an
`UnsatisfiedLinkError` because zstd-jni cannot load its native library, or a
`NoSuchMethodError` from an older commons-io on the classpath, the error
escapes the interceptor and gRPC closes the call with its own status, with no
`ErrorInfo` or error ID, just as before this change. The interceptor is the
only caller of the `ServerCall` variant of `handleError`, so this case never
takes effect through that variant. PySpark sends compressed plans whenever a
plan exceeds `spark.connect.session.planCompression.threshold` (10 MB by
default) and `zstandard` is installed. Letting that catch also hand
`LinkageError` to `handleError` woul
d cover this path.
**Verification:**
- **Regression:** For a session that already exists, when plan decompression
throws a linkage error such as NoClassDefFoundError, the interceptor closes the
call with INTERNAL, an ErrorInfo whose reason is that class, and an error ID
that FetchErrorDetails resolves when error enrichment is on.
- **Compatibility:** A corrupted compressed plan still closes the call with
the same error status and trailers as before, and a fatal error that is not a
linkage error, raised during decompression, still propagates out of the
interceptor instead of being caught.
##########
sql/connect/server/src/test/scala/org/apache/spark/sql/connect/service/FetchErrorDetailsHandlerSuite.scala:
##########
@@ -93,6 +96,54 @@ class FetchErrorDetailsHandlerSuite extends
SharedSparkSession with ResourceHelp
ThreadUtils.awaitResult(promise.future, 5.seconds)
}
+ for (testError <- Seq(
Review Comment:
**Nit (P3):** These cases cover only `LinkageError` subclasses, and the
existing fallback test in `ErrorUtilsSuite` uses `InterruptedException`, which
is not an `Error`. If the new arm were widened to `case e: Error`, no test
would fail, even though `OutOfMemoryError` and `StackOverflowError` would then
take the structured path, which renders JSON metadata and, with error
enrichment on, caches the throwable under a new error ID, contrary to the PR's
statement that other fatal errors keep the existing fallback.
**Verification:**
- **Behavior:** Passing an Error that is not a linkage error, such as
StackOverflowError, to handleError yields UNKNOWN with the class name as its
description, no ErrorInfo detail, and nothing cached for FetchErrorDetails.
- **Regression:** The new case fails when the linkage-error arm is widened
to match every Error, while the existing linkage-error and InterruptedException
cases keep passing.
##########
sql/connect/server/src/main/scala/org/apache/spark/sql/connect/utils/ErrorUtils.scala:
##########
@@ -355,6 +355,10 @@ private[connect] object ErrorUtils extends Logging {
case e: Throwable if e.isInstanceOf[SparkThrowable] || NonFatal.apply(e)
=>
StatusProto.toStatusRuntimeException(buildStatusFromThrowable(e,
sessionHolderOpt))
+ // Linkage errors are excluded by NonFatal but still need structured JVM
error details.
+ case e: LinkageError =>
+ StatusProto.toStatusRuntimeException(buildStatusFromThrowable(e,
sessionHolderOpt))
Review Comment:
**Non-blocking (P2):** By the review's reading of the code, this call can
throw the same linkage error it is handling. `buildStatusFromThrowable` reads
`session.sessionState.conf` (lines 250-251 and 263-264), Connect sessions build
their `SessionState` lazily, and `instantiateSessionState` wraps only
`NonFatal` failures. When a `spark.sql.extensions` jar built for another Spark
version makes the parser or columnar-rule builder throw, say,
`NoSuchMethodError`, the lazy value stays unset, so this read re-runs the
failing build and the error escapes `handleError` before it logs, posts the
failure event, runs callbacks or calls `onError`. On the default reattachable
ExecutePlan path, both the execution thread and the response-sender thread then
exit without closing the stream, so the client waits for its own stream
deadline (10 minutes in PySpark) instead of getting the error at once; on
handler threads such as AnalyzePlan, gRPC closes the call without the error's
description. Before
this change these errors took the UNKNOWN fallback below, which needs nothing
from the session, so falling back to it when building the structured status
throws would keep this case's benefit.
**Verification:**
- **Regression:** Take a Connect session whose state cannot be built because
an injected session-extension builder throws a linkage error. Handling that
linkage error closes the stream with UNKNOWN carrying the error's description,
posts the failure event and runs the cleanup callback, instead of throwing out
of the handler.
- **Regression:** In a reattachable execution whose session state cannot be
built for that reason, the response sender ends the client's stream with the
error, so the client receives a failure rather than waiting on an open stream.
- **Compatibility:** Linkage errors whose structured status builds normally
still return INTERNAL with ErrorInfo and an error ID that FetchErrorDetails
resolves, and fatal errors that are not linkage errors still get the UNKNOWN
fallback.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]