Skip to content

Commit 93d359f

Browse files
committed
Executors connect to wrong port when collision occurs
This commit fixes this by setting "spark.driver.port" to the actual port the akka system bound to. Note that we already do this for port 0, where the original port is not the same as the bound port. However, we still face the same issue if we end up using port n + 1.
1 parent d502e5f commit 93d359f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/src/main/scala/org/apache/spark/SparkEnv.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ object SparkEnv extends Logging {
150150
val (actorSystem, boundPort) = AkkaUtils.createActorSystem("spark", hostname, port, conf = conf,
151151
securityManager = securityManager)
152152

153-
// Bit of a hack: If this is the driver and our port was 0 (meaning bind to any free port),
154-
// figure out which port number Akka actually bound to and set spark.driver.port to it.
155-
if (isDriver && port == 0) {
156-
conf.set("spark.driver.port", boundPort.toString)
153+
// Figure out which port Akka actually bound to in case the original port is 0 or occupied.
154+
// This is so that we tell the executors the correct port to connect to.
155+
if (isDriver) {
156+
conf.set("spark.driver.port", boundPort.toString)
157157
}
158158

159159
// Create an instance of the class named by the given Java system property, or by

0 commit comments

Comments
 (0)