tdas commented on a change in pull request #26771: [SPARK-30143][SS] Add a 
timeout on stopping a streaming query
URL: https://github.com/apache/spark/pull/26771#discussion_r354646282
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamExecution.scala
 ##########
 @@ -434,6 +434,26 @@ abstract class StreamExecution(
     }
   }
 
+  /**
+   * Interrupts the query execution thread and awaits its termination until the
+   * `spark.sql.streaming.stopTimeout`. A timeout of 0 milliseconds will block 
indefinitely.
+   *
+   * @throws TimeoutException If the thread cannot be stopped within the 
timeout
+   * @throws IllegalArgumentException If the timeout is set as a negative value
+   */
+  protected def interruptAndAwaitExecutionThreadTermination(): Unit = {
+    val timeout = 
sparkSession.sessionState.conf.getConf(SQLConf.STREAMING_STOP_TIMEOUT)
+    queryExecutionThread.interrupt()
+    queryExecutionThread.join(timeout)
+    if (queryExecutionThread.isAlive) {
+      val timeoutException = new TimeoutException(
+        s"Stream Execution thread failed to stop within $timeout milliseconds. 
See stack trace " +
+        "on what was being last executed.")
 
 Review comment:
   was being executed in the streaming query thread.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to