[SERVER-26600] mongod should fail to start on macOS when it can't listen port on all interfaces Created: 12/Oct/16 Updated: 04/Nov/16 Resolved: 31/Oct/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Networking |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Andrey Brindeyev | Assignee: | Mira Carey |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Operating System: | OS X |
| Sprint: | Platforms 2016-10-31 |
| Participants: |
| Description |
|
On macOS you can have two different mongod's listening on same port: one with a specific IP addresses to bind to and second one with an empty list. Can't reproduce this behavior on Linux.
There are no warnings or errors for mongod running with default configuration (PID 90613):
|
| Comments |
| Comment by Mira Carey [ 26/Oct/16 ] | ||||||||||
|
You're observing a difference in the effect that SO_REUSADDR has on Linux versus BSD. In the original Berkeley Sockets implementation (which OSX inherits) SO_REUSEADDR allows for binding a socket to an address unless there is an exact collision of source address and port. Specifically, it allows for binds against INADDR_ANY (0.0.0.0) that resolve to a particular physical interface as well as binds to that interface specifically. In comparison, linux diverges and considers INADDR_ANY and the interface it resolves to, to be in collision. On all platforms, the reason we use SO_REUSEADDR is so that quickly after a restart of a mongod, the next process will be able to bind to the port, rather than having to wait for all the tcp sessions to fully time out (leave TIME_WAIT). The downstream effect on other concurrent binding processes is fallout from how the OS implements that socket option. | ||||||||||
| Comment by Vick Mena (Inactive) [ 12/Oct/16 ] | ||||||||||
|
For completeness I'm adding the following which shows you can do the same thing with netcat on OSX. So now I'm not sure if this is an application issue or an OSX hidden feature. nc -v -l 12999& COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME And on Linux the same application also behaves differently: | ||||||||||
| Comment by Jorge Imperial-Sosa [ 12/Oct/16 ] | ||||||||||
|
I can confirm the behavior is the same in OS X 15.6.0.
|