HyukjinKwon commented on code in PR #49880:
URL: https://github.com/apache/spark/pull/49880#discussion_r1950696487
##########
sql/connect/common/src/main/scala/org/apache/spark/sql/connect/SparkSession.scala:
##########
@@ -712,37 +730,45 @@ object SparkSession extends SparkSessionCompanion with
Logging {
}
}
- val maybeConnectScript =
- Option(System.getenv("SPARK_HOME")).map(Paths.get(_, "sbin",
"start-connect-server.sh"))
-
- if (server.isEmpty &&
- (remoteString.exists(_.startsWith("local")) ||
- (remoteString.isDefined && isAPIModeConnect)) &&
- maybeConnectScript.exists(Files.exists(_))) {
- server = Some {
- val args =
- Seq(maybeConnectScript.get.toString, "--master", remoteString.get)
++ sparkOptions
- .filter(p => !p._1.startsWith("spark.remote"))
- .flatMap { case (k, v) => Seq("--conf", s"$k=$v") }
- val pb = new ProcessBuilder(args: _*)
- // So don't exclude spark-sql jar in classpath
- pb.environment().remove(SparkConnectClient.SPARK_REMOTE)
- pb.start()
- }
-
- // Let the server start. We will directly request to set the
configurations
- // and this sleep makes less noisy with retries.
- Thread.sleep(2000L)
- System.setProperty("spark.remote", "sc://localhost")
-
- // scalastyle:off runtimeaddshutdownhook
- Runtime.getRuntime.addShutdownHook(new Thread() {
- override def run(): Unit = if (server.isDefined) {
- new ProcessBuilder(maybeConnectScript.get.toString)
- .start()
+ server.synchronized {
Review Comment:
Just added a `synchronized`.
--
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]