[SERVER-78384] mongos should allow --port 0 Created: 23/Jun/23 Updated: 06/Nov/23 Resolved: 30/Jun/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0, 5.0.22, 7.0.3, 4.4.26, 6.0.12 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Anna Henningsen | Assignee: | Amirsaman Memaripour |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Assigned Teams: |
Service Arch
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Backport Requested: |
v7.0, v6.0, v5.0, v4.4
|
||||||||||||||||||||||||
| Steps To Reproduce: | mongos --port 0 |
||||||||||||||||||||||||
| Sprint: | Service Arch 2023-07-10 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
mongos, unlike mongod, does not allow listening on an arbitrary OS-assigned port by specifying --port 0. In ancient times (2010), validation for --port was added to the server. Then, in slightly less ancient times (2013), this validation was split into separate validation code for mongod and mongos. And then, in not-even-all-that-long-ago times (2017), the validation for mongod was updated to allow port 0, but no such update was done for the corresponding mongos argument validation. We should apply that update there as well. |
| Comments |
| Comment by Githook User [ 06/Nov/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) GitOrigin-RevId: 1336e91500cf661a4a63a7c388bd7f38e75658ad |
| Comment by Githook User [ 05/Nov/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) GitOrigin-RevId: f4b6a1339727ca3aee6fc7cbe33fbbb74167d9c5 |
| Comment by Githook User [ 05/Nov/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) GitOrigin-RevId: 239b9638dba2209e18c8ea91e3567f190b3781cc |
| Comment by Githook User [ 04/Nov/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) GitOrigin-RevId: 38713499c32d4d937b5085183824491e83223c82 |
| Comment by Githook User [ 14/Oct/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) GitOrigin-RevId: c01215d47aa8566f0da914203659d57c17d4212f |
| Comment by Githook User [ 13/Oct/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) |
| Comment by Githook User [ 13/Oct/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) |
| Comment by Githook User [ 10/Oct/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: (cherry picked from commit 7e059e2b54cbab335d4d5d3d7b66ced74c4424f5) |
| Comment by Githook User [ 03/Jul/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: |
| Comment by Githook User [ 28/Jun/23 ] |
|
Author: {'name': 'Saman Memaripour', 'email': 'amirsaman.memaripour@mongodb.com', 'username': 'samanca'}Message: |
| Comment by Felipe Gasper [ 28/Jun/23 ] |
|
How possible would it be to allow mongod & mongos to accept a pre-created socket, e.g. `--port=fd5`? That’d look like:
… then mongod/mongos would just take that fd rather than creating/binding their own. That’s a much cleaner way of achieving the same result that I, at least, am looking for. |
| Comment by Eric Milkie [ 28/Jun/23 ] |
|
That last commit from 2017 that started to allow port 0 almost seems like a mistake, since the rest of the changes are only tangentially related and no mention of the new behavior was made in either the Jira ticket or the commit description. |
| Comment by Felipe Gasper [ 28/Jun/23 ] |
|
(Really, the best for testing would be if mongod & mongos could accept a socket on a file descriptor, but fishing the port out of the log works for now.) |
| Comment by Felipe Gasper [ 28/Jun/23 ] |
|
While working on REP-2831 I ran across this problem independently of this ticket. `--port 0` is useful for reliably starting a mongos without needing to pre-allocate a port. It’s possible, of course, to pre-bind to port 0, read that socket’s actual port, close the socket, then reuse the port, but that’s not race-safe. |
| Comment by Alex Neben [ 26/Jun/23 ] |
|
Moving to service arch since this is C++ startup params. |