Skip to content

Commit ed763c5

Browse files
committed
Listen on the first free port from 9009
Partially reverts the backport of #21818 in 0.6.1. Fixes #24722. Remove support for OSX client port reuse.
1 parent 3522df1 commit ed763c5

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

NEWS.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ This section lists changes that do not have deprecation warnings.
259259
rather than from environment variables ([#19636]).
260260
261261
* Workers now listen on an ephemeral port assigned by the OS. Previously workers would
262-
listen on the first free port available from 9009 ([#21818]).
262+
listen on the first free port available from 9009 ([#21818]). Version 0.6.1 only.
263+
Reverted in 0.6.2
263264
264265
265266
Library improvements

base/distributed/cluster.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function start_worker(out::IO, cookie::AbstractString)
153153
init_worker(cookie)
154154
interface = IPv4(LPROC.bind_addr)
155155
if LPROC.bind_port == 0
156-
(port, sock) = listenany(interface, UInt16(0))
156+
(port, sock) = listenany(interface, UInt16(9009))
157157
LPROC.bind_port = port
158158
else
159159
sock = listen(interface, LPROC.bind_port)

base/distributed/managers.jl

+7-1
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,13 @@ end
456456
const client_port = Ref{Cushort}(0)
457457

458458
function socket_reuse_port()
459-
@static if is_linux() || is_apple()
459+
460+
# Revert OSX support for now. On OSX, client socket port number reuse
461+
# does not play well in a scenario where worker processes are repeatedly
462+
# created and torn down, i.e., when the new workers end up reusing a
463+
# a previous listen port.
464+
# @static if is_linux() || is_apple()
465+
@static if is_linux()
460466
s = TCPSocket(delay = false)
461467

462468
# Linux requires the port to be bound before setting REUSEPORT, OSX after.

doc/src/manual/parallel-computing.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1231,8 +1231,8 @@ as local laptops, departmental clusters, or even the cloud. This section covers
12311231
requirements for the inbuilt `LocalManager` and `SSHManager`:
12321232

12331233
* The master process does not listen on any port. It only connects out to the workers.
1234-
* Each worker binds to only one of the local interfaces and listens on an ephemeral port number
1235-
assigned by the OS.
1234+
* Each worker binds to only one of the local interfaces and listens on the first free port starting
1235+
from `9009`.
12361236
* `LocalManager`, used by `addprocs(N)`, by default binds only to the loopback interface. This means
12371237
that workers started later on remote hosts (or by anyone with malicious intentions) are unable
12381238
to connect to the cluster. An `addprocs(4)` followed by an `addprocs(["remote_host"])` will fail.
@@ -1250,9 +1250,8 @@ requirements for the inbuilt `LocalManager` and `SSHManager`:
12501250
authenticated via public key infrastructure (PKI). Authentication credentials can be supplied
12511251
via `sshflags`, for example ```sshflags=`-e <keyfile>` ```.
12521252

1253-
In an all-to-all topology (the default), all workers connect to each other via plain TCP sockets.
1254-
The security policy on the cluster nodes must thus ensure free connectivity between workers for
1255-
the ephemeral port range (varies by OS).
1253+
Note that worker-worker connections are still plain TCP and the local security policy on the remote
1254+
cluster must allow for free connections between worker nodes, at least for ports 9009 and above.
12561255

12571256
Securing and encrypting all worker-worker traffic (via SSH) or encrypting individual messages
12581257
can be done via a custom ClusterManager.

0 commit comments

Comments
 (0)