slamke commented on a change in pull request #27724: [SPARK-30973][SQL] 
ScriptTransformationExec should wait for the termination …
URL: https://github.com/apache/spark/pull/27724#discussion_r386969280
 
 

 ##########
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/ScriptTransformationExec.scala
 ##########
 @@ -161,6 +161,7 @@ case class ScriptTransformationExec(
 
               if (scriptOutputReader != null) {
                 if (scriptOutputReader.next(scriptOutputWritable) <= 0) {
 
 Review comment:
   No, I find a way to reproduce. Just run this code in laptop for some times, 
it will show that when `inputStream` return -1, but the `proc` is alive. 
Actually, `ScriptTransformationExec ` also uses `inputStream` to check the end 
of stream.
   
   ``` scala 
   import scala.collection.JavaConverters._
   
   object SparkTEST {
     def main(args: Array[String]): Unit = {
       var i = 0
       for (i <- 0 until (50)) {
         check_script()
       }
     }
   
     def check_script() = {
       val script = "python error_python.py"
       val cmd = List("/bin/bash", "-c", script)
       val builder = new ProcessBuilder(cmd.asJava)
       val proc = builder.start()
       val inputStream = proc.getInputStream
       var msg = ""
       if (inputStream.read() <= 0) {
         msg = s"Cannot read inputStream and proc status is: ${if 
(proc.isAlive) "alive" else "dead"}"
       }
       println(msg)
     }
   }
   ```

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