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_r354646706
##########
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.")
+ timeoutException.setStackTrace(queryExecutionThread.getStackTrace)
Review comment:
I am not sure this is a good idea to replace the stack trace of the
exception completely. This is unusual and could cause a lot of confusion when
trying to trace back this exception to the code. Rather put the stack trace in
the message (like driver job exception embeds the task exception) or make it a
cause of this exception.
----------------------------------------------------------------
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]