Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11746#discussion_r57396560
  
    --- Diff: 
core/src/main/scala/org/apache/spark/deploy/worker/DriverRunner.scala ---
    @@ -181,42 +211,43 @@ private[deploy] class DriverRunner(
         runCommandWithRetry(ProcessBuilderLike(builder), initialize, supervise)
       }
     
    -  def runCommandWithRetry(
    -      command: ProcessBuilderLike, initialize: Process => Unit, supervise: 
Boolean): Unit = {
    +  private[worker] def runCommandWithRetry(
    +      command: ProcessBuilderLike, initialize: Process => Unit, supervise: 
Boolean): Int = {
         // Time to wait between submission retries.
         var waitSeconds = 1
         // A run of this many seconds resets the exponential back-off.
         val successfulRunDuration = 5
    +    var attemptRun = true
    +    var exitCode = -1
     
    -    var keepTrying = !killed
    -
    -    while (keepTrying) {
    +    while (attemptRun) {
           logInfo("Launch Command: " + command.command.mkString("\"", "\" \"", 
"\""))
     
    -      synchronized {
    -        if (killed) { return }
    -        process = Some(command.start())
    -        initialize(process.get)
    -      }
    +      process = command.start()
    +      initialize(process)
     
           val processStart = clock.getTimeMillis()
    -      val exitCode = process.get.waitFor()
    -      if (clock.getTimeMillis() - processStart > successfulRunDuration * 
1000) {
    -        waitSeconds = 1
    -      }
     
    -      if (supervise && exitCode != 0 && !killed) {
    +      exitCode = process.waitFor()
    +      process = null
    +
    +      // check if attempting another run
    +      attemptRun = supervise && exitCode != 0
    +      if (attemptRun) {
    +        if (clock.getTimeMillis() - processStart > successfulRunDuration * 
1000) {
    +          waitSeconds = 1
    +        }
             logInfo(s"Command exited with status $exitCode, re-launching after 
$waitSeconds s.")
             sleeper.sleep(waitSeconds)
             waitSeconds = waitSeconds * 2 // exponential back-off
           }
    -
    -      keepTrying = supervise && exitCode != 0 && !killed
    -      finalExitCode = Some(exitCode)
         }
    +
    +    exitCode
       }
     }
     
    +
    --- End diff --
    
    nit: extra space


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to