pan3793 commented on code in PR #7797:
URL: https://github.com/apache/kyuubi/pull/7797#discussion_r4396166572
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala:
##########
@@ -410,7 +409,14 @@ object SparkSQLEngine extends Logging {
try {
startEngine(spark)
// blocking main thread
- countDownLatch.await()
+ // The engine may not reach stopServer after SparkContext shutdown
starts.
+ while (!countDownLatch.await(1, TimeUnit.SECONDS)) {
+ if (spark.sparkContext.isStopped) {
+ // stop() may already be running, so exit the wait instead of
calling it again.
+ warn("SparkContext has been stopped, breaking main thread wait")
+ return
Review Comment:
Throw a `KyuubiException` here instead of returning. If SparkContext stops
before the latch is released, the engine is terminating abnormally. A normal
return makes YARN report the app as SUCCEEDED and spark-submit exit 0. Throwing
also reuses the catch below: it calls `engine.stop()` (a no-op if a stop is
already in flight, because of `shutdown.compareAndSet`), posts the end
`EngineEvent` with diagnostics, and logs at error level.
```scala
while (!countDownLatch.await(1, TimeUnit.SECONDS)) {
if (spark.sparkContext.isStopped) {
throw new KyuubiException(
"SparkContext stopped before SparkSQLEngine, terminating the engine
main thread")
}
}
```
Please also update the comment above the loop to match.
##########
externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala:
##########
@@ -227,7 +227,6 @@ object SparkSQLEngine extends Logging {
private lazy val user = currentUser
private val countDownLatch = new CountDownLatch(1)
-
Review Comment:
Unrelated change, please revert.
--
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]