viirya commented on code in PR #60540:
URL: https://github.com/apache/spark/pull/60540#discussion_r4583881377
##########
core/src/test/scala/org/apache/spark/api/python/BasePythonRunnerSuite.scala:
##########
@@ -1108,7 +1111,120 @@ class BasePythonRunnerSuite extends SparkFunSuite with
SharedSparkContext {
"Idle timeout reached for Python worker (timeout: 3 seconds). " +
"No data received from the worker process - handle.map(_.isAlive) =
None, " +
s"$blockingWorkerStatus - $task"))
- handler.throwIfKilled(-1)
+ assert(handler.read(-1) === -1)
+ }
+ }
+
+ /**
+ * Closes `peer` so that the other end of the connection sees a reset
instead of the end of
+ * the stream, like the connection of a worker that is killed while it has
unread input.
+ */
+ private def reset(peer: SocketChannel): Unit = {
+ peer.setOption[Integer](StandardSocketOptions.SO_LINGER, 0)
+ peer.close()
+ }
+
+ test("a read that fails after the idle timeout killed the worker reports the
idle timeout") {
+ // Pipelined mode: the read times out, the worker is killed, and the read
that is tried
+ // again fails with a connection reset.
+ withIdleWorker(blocking = true) { (worker, peer) =>
+ val handle = new RecordingWorkerHandle(
+ diagnostics = Some("worker stack"), onDestroy = () => reset(peer))
+ val handler = new BasePythonRunner.IdleTimeoutHandler(
+ worker, Some(handle), idleTimeoutSeconds = 1, killOnIdleTimeout = true,
+ Some(TaskContext.empty()), idleTimeoutLoggerName)
+ worker.channel.socket().setSoTimeout(1000)
Review Comment:
Done: `setSoTimeout(10)` for the blocking case and a direct `onIdleTimeout`
for the selector case.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]