You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ya...@apache.org on 2024/12/11 04:56:59 UTC

(spark) branch branch-3.5 updated: [SPARK-50510][CONNECT][3.5] Fix sporadic ReattachableExecuteSuite failure

This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-3.5 by this push:
     new bb953f97e6c5 [SPARK-50510][CONNECT][3.5] Fix sporadic ReattachableExecuteSuite failure
bb953f97e6c5 is described below

commit bb953f97e6c5a26861296aca0a4f14db078ef2ef
Author: changgyoopark-db <ch...@databricks.com>
AuthorDate: Wed Dec 11 12:56:43 2024 +0800

    [SPARK-50510][CONNECT][3.5] Fix sporadic ReattachableExecuteSuite failure
    
    ### What changes were proposed in this pull request?
    
    ReattachableExecuteSuite detected a rare data race issue where ExecuteThreadRunner may send the client the wrong error code before the SparkConnect service sends the correct error code.
    - The test fails if ExecuteThreadRunner is finished before the SparkConnect service sends the correct error code and after the session is invalidated; to be specific, the event manager throws an illegal state exception (SPARK-49688) that is translated into an unknown error.
    - The whole problem was addressed under https://github.com/apache/spark/pull/48208 for Spark 4.0.
    
    ### Why are the changes needed?
    
    1. Clients may get the wrong error message: expect session-closed or the like, but get unknown.
    2. To fix the ReattachableExecuteSuite failure.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    ReattachableExecuteSuite.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #49127 from changgyoopark-db/SPARK-50510.
    
    Authored-by: changgyoopark-db <ch...@databricks.com>
    Signed-off-by: yangjie01 <ya...@baidu.com>
---
 .../org/apache/spark/sql/connect/service/ExecuteHolder.scala   | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/ExecuteHolder.scala b/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/ExecuteHolder.scala
index 0e4f344da901..93a1757cd687 100644
--- a/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/ExecuteHolder.scala
+++ b/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/ExecuteHolder.scala
@@ -21,6 +21,7 @@ import java.util.UUID
 
 import scala.collection.JavaConverters._
 import scala.collection.mutable
+import scala.util.control.NonFatal
 
 import org.apache.spark.{SparkEnv, SparkSQLException}
 import org.apache.spark.connect.proto
@@ -237,7 +238,14 @@ private[connect] class ExecuteHolder(
         // it does.
         responseObserver.removeAll()
         // post closed to UI
-        eventsManager.postClosed()
+        try {
+          eventsManager.postClosed()
+        } catch {
+          // Catching the exception to prevent the wrong error code from being returned to the
+          // user: SPARK-49688. The issue was fixed by completely refactoring the code in Spark 4.0.
+          case e: Throwable if NonFatal.apply(e) =>
+            logError(s"Error posting closed event to UI: ${e.getMessage()}")
+        }
       }
       // interrupt any attached grpcResponseSenders
       grpcResponseSenders.foreach(_.interrupt())


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