jeremyjliu commented on a change in pull request #24811: [SPARK-27962][R][CORE] 
Propagate subprocess stdout in deploy.RRunner in exception
URL: https://github.com/apache/spark/pull/24811#discussion_r293177686
 
 

 ##########
 File path: core/src/main/scala/org/apache/spark/deploy/RRunner.scala
 ##########
 @@ -100,15 +100,17 @@ object RRunner {
         builder.redirectErrorStream(true) // Ugly but needed for stdout and 
stderr to synchronize
         val process = builder.start()
 
-        new RedirectThread(process.getInputStream, System.out, "redirect R 
output").start()
+        val stdoutBuffer = new CircularBuffer(1024)
+        val output = new TeeOutputStream(System.out, stdoutBuffer)
+        new RedirectThread(process.getInputStream, output, "redirect R 
output").start()
 
-        process.waitFor()
+        val returnCode = process.waitFor()
+        if (returnCode != 0) {
+          throw SparkUserAppException(returnCode, 
Option(stdoutBuffer.toString))
+        }
       } finally {
         sparkRBackend.close()
       }
-      if (returnCode != 0) {
 
 Review comment:
    Before (stacktrace truncated):
   ```
   org.apache.spark.SparkUserAppException: User application exited with exit 
code 127
   ```
   
   And after:
   ```
   org.apache.spark.SparkUserAppException: User application exited with exit 
code 127 and message /<path-to-R>/R: error while loading shared libraries: 
libiconv.so.2: cannot open shared object file: No such file or directory
   ```

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