You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "hvanhovell (via GitHub)" <gi...@apache.org> on 2023/08/06 19:27:28 UTC

[GitHub] [spark] hvanhovell commented on a diff in pull request #42355: [WIP][CONNECT] Return from executePlan / reattachExecute handler and process stream on different thread

hvanhovell commented on code in PR #42355:
URL: https://github.com/apache/spark/pull/42355#discussion_r1285254250


##########
connector/connect/server/src/main/scala/org/apache/spark/sql/connect/execution/ExecuteGrpcResponseSender.scala:
##########
@@ -58,6 +61,39 @@ private[connect] class ExecuteGrpcResponseSender[T <: MessageLite](
     detached = true
   }
 
+  def run(lastConsumedStreamIndex: Long): Unit = {
+
+    // In reattachable execution, we check if grpcCallObserver is ready for sending.
+    // See sendResponse
+    if (executeHolder.reattachable && flowControl) {
+      val grpcCallObserver = grpcObserver.asInstanceOf[ServerCallStreamObserver[T]]
+      grpcCallObserver.setOnReadyHandler(() => {
+        val e = new Exception()
+        logError(s"ON READY\n${e.getStackTrace.mkString("\n")}")
+        grpcCallObserverReadySignal.synchronized {
+          grpcCallObserverReadySignal.notifyAll()
+        }
+      })
+    }
+
+    // We run in a separate daemon thread
+    val t = new Thread {
+      override def run(): Unit = {
+        try {
+          execute(lastConsumedStreamIndex)
+        } finally {
+          if (!executeHolder.reattachable) {
+            // Non reattachable executions release here immediately.
+            // (Reattachable executions close release with ReleaseExecute RPC.)
+            executeHolder.close()
+          }
+        }
+      }
+    }
+    t.setDaemon(true) // can I not set daemon and just don't join?

Review Comment:
   If you do that and the application tries to terminate it won't... You don't have to join.



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