AngersZhuuuu opened a new pull request, #35594:
URL: https://github.com/apache/spark/pull/35594
### What changes were proposed in this pull request?
Current Spark SQL CLI alway use shutdown hook to stop SparkSQLEnv
```
// Clean up after we exit
ShutdownHookManager.addShutdownHook { () => SparkSQLEnv.stop() }
```
but use process ret to close client side jvm
```
while (line != null) {
if (!line.startsWith("--")) {
if (prefix.nonEmpty) {
prefix += '\n'
}
if (line.trim().endsWith(";") && !line.trim().endsWith("\\;")) {
line = prefix + line
ret = cli.processLine(line, true)
prefix = ""
currentPrompt = promptWithCurrentDB
} else {
prefix = prefix + line
currentPrompt = continuedPromptWithDBSpaces
}
}
line = reader.readLine(currentPrompt + "> ")
}
sessionState.close()
System.exit(ret)
}
```
```
if (sessionState.execString != null) {
exitCode = cli.processLine(sessionState.execString)
System.exit(exitCode)
}
try {
if (sessionState.fileName != null) {
exitCode = cli.processFile(sessionState.fileName)
System.exit(exitCode)
}
} catch {
case e: FileNotFoundException =>
logError(s"Could not open input file for reading. (${e.getMessage})")
exitCode = 3
System.exit(exitCode)
}
```
This always cause client side exit code not consistent with AM.
IN this pr I prefer to pass the exit code to `SparkContext.stop()` method to
pass a clear client side status to AM side in client mode.
In this pr, I add a new `stop` method in `SchedulerBackend`
```
def stop(exitCode: Int): Unit = stop()
```
So we don't need to implement it for all kinds of scheduler backend.
In this pr, we only handle the case me meet for
`YarnClientSchedulerBackend`, then we can only implement `stop(exitCode: Int)`
for this class, then for yarn client mode, it can work now.
I think this can benefit many similar case in future.
### Why are the changes needed?
Keep client side status consistent with AM side
### Does this PR introduce _any_ user-facing change?
With this pr, client side status will be same with am side
### How was this patch tested?
MT
--
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]