You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "pan3793 (via GitHub)" <gi...@apache.org> on 2025/12/01 06:55:14 UTC

Re: [PR] [SPARK-54550][CONNECT] Handle `ConnectException` gracefully in `SparkConnectStatement.close()` [spark]

pan3793 commented on code in PR #53260:
URL: https://github.com/apache/spark/pull/53260#discussion_r2575832480


##########
sql/connect/client/jdbc/src/main/scala/org/apache/spark/sql/connect/client/jdbc/SparkConnectStatement.scala:
##########
@@ -35,14 +35,21 @@ class SparkConnectStatement(conn: SparkConnectConnection) extends Statement {
   override def close(): Unit = synchronized {
     if (!closed) {
       if (operationId != null) {
-        conn.spark.interruptOperation(operationId)
+        try {
+          conn.spark.interruptOperation(operationId)
+        } catch {
+          case _: java.net.ConnectException =>
+            // Ignore ConnectExceptions during cleanup as the operation may have already completed
+            // or the server may be unavailable. The important part is marking this statement
+            // as closed to prevent further use.

Review Comment:
   @vinodkc I think the reviewer does not reach a consensus to swallow this exception, and I tend to agree with @cloud-fan's last comments
   
   https://github.com/apache/spark/pull/53236#issuecomment-3587886559
   
   > If the driver is crashed, it doesn't help to swallow the error when closing the statement, as the next test case will still fail.



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