viirya commented on a change in pull request #21164: [SPARK-24098][SQL] 
ScriptTransformationExec should wait process exiting before output iterator 
finish
URL: https://github.com/apache/spark/pull/21164#discussion_r333223463
 
 

 ##########
 File path: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/ScriptTransformationExec.scala
 ##########
 @@ -137,13 +137,12 @@ case class ScriptTransformationExec(
             throw writerThread.exception.get
           }
 
-          if (!proc.isAlive) {
-            val exitCode = proc.exitValue()
-            if (exitCode != 0) {
-              logError(stderrBuffer.toString) // log the stderr circular buffer
-              throw new SparkException(s"Subprocess exited with status 
$exitCode. " +
-                s"Error: ${stderrBuffer.toString}", cause)
-            }
+          proc.waitFor()
 
 Review comment:
   I tested with provided python script. Actually at 
ScriptTransformationWriterThread, no exception is thrown. 
   
   And, checkFailureAndPropagate is called not due to EOFException, it is 
called at:
   
   
https://github.com/apache/spark/blob/8a17d26784c53fb50b6373b566aab71135c8956f/sql/hive/src/main/scala/org/apache/spark/sql/hive/execution/ScriptTransformationExec.scala#L163-L167
   
   In this case, checkFailureAndPropagate can be called before proc is being 
terminated due to possible lag, so the !proc.isAlive check fails.
   
   I think the fix is to add proc.waitFor() before other 
checkFailureAndPropagate calls.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to