anishshri-db commented on code in PR #52318: URL: https://github.com/apache/spark/pull/52318#discussion_r2342423095
########## sql/core/src/main/scala/org/apache/spark/sql/execution/python/streaming/TransformWithStateInPySparkStateServer.scala: ########## @@ -172,15 +172,32 @@ class TransformWithStateInPySparkStateServer( logWarning(log"No more data to read from the socket") statefulProcessorHandle.setHandleState(StatefulProcessorHandleState.CLOSED) return - case _: InterruptedException => + case _: InterruptedException | _: InterruptedIOException | + _: ClosedByInterruptException => + // InterruptedIOException - thrown when an I/O operation is interrupted + // ClosedByInterruptException - thrown when an I/O operation upon a channel is interrupted logInfo(log"Thread interrupted, shutting down state server") Thread.currentThread().interrupt() statefulProcessorHandle.setHandleState(StatefulProcessorHandleState.CLOSED) return case e: Exception => logError(log"Error reading message: ${MDC(LogKeys.ERROR, e.getMessage)}", e) - sendResponse(1, e.getMessage) - outputStream.flush() + try { + sendResponse(1, e.getMessage) + outputStream.flush() + } catch { + // InterruptedIOException - thrown when an I/O operation is interrupted + // ClosedByInterruptException - thrown when an I/O operation upon a + // channel is interrupted + case _: InterruptedException | _: InterruptedIOException | + _: ClosedByInterruptException => + logInfo(log"Thread is interrupted during flushing error response, " + + "shutting down state server") + case e: Throwable => + logError(log"Error during flushing error response: " + Review Comment: `Failed to flush with errorMsg=` ? -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org