[SERVER-10244] Fail gracefully on invalid port number Created: 17/Jul/13  Updated: 10/Dec/14  Resolved: 26/Feb/14

Status: Closed
Project: Core Server
Component/s: Usability
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Ernie Hershey Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-7808 mongos allows you to specify an inval... Closed
Related
is related to SERVER-8030 mongo shell crashes with missing host Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

If I pass an invalid port to mongod it prints a stack trace after the error message. It should just print the error.

[ernie@eahimac ~]$ ./mongodb-osx-x86_64-2.4.5/bin/mongod --port 123123
Wed Jul 17 17:10:18.557 bad --port number
Wed Jul 17 17:10:18.557 dbexit:
Wed Jul 17 17:10:18.557 shutdown: going to close listening sockets...
Wed Jul 17 17:10:18.557 shutdown: going to flush diaglog...
Wed Jul 17 17:10:18.557 shutdown: going to close sockets...
Wed Jul 17 17:10:18.557 shutdown: waiting for fs preallocator...
Wed Jul 17 17:10:18.557 shutdown: lock for final commit...
Wed Jul 17 17:10:18.557 Assertion failure c src/mongo/db/client.h 235
0x100447d8b 0x100421aec 0x100136a88 0x100136bc3 0x100136e4b 0x100136f78 0x1001e49bd 0x1000093a5 0x10000b593 0x1000010b4
0 mongod 0x0000000100447d8b _ZN5mongo15printStackTraceERSo + 43
1 mongod 0x0000000100421aec _ZN5mongo12verifyFailedEPKcS1_j + 284
2 mongod 0x0000000100136a88 _ZN5mongo4Lock10ScopedLock6relockEv + 0
3 mongod 0x0000000100136bc3 _ZN5mongo4Lock10ScopedLockC2Ec + 39
4 mongod 0x0000000100136e4b _ZN5mongo4Lock10GlobalReadC2Ei + 29
5 mongod 0x0000000100136f78 _ZN5mongo11readlocktryC2Ei + 50
6 mongod 0x00000001001e49bd _ZN5mongo6dbexitENS_8ExitCodeEPKc + 861
7 mongod 0x00000001000093a5 _ZL25processCommandLineOptionsRKSt6vectorISsSaISsEE + 17397
8 mongod 0x000000010000b593 main + 467
9 mongod 0x00000001000010b4 start + 52
Wed Jul 17 17:10:18.581 shutdown failed with exception
Wed Jul 17 17:10:18.581 dbexit: really exiting now
[ernie@eahimac ~]$

The 2.5 shell is nicer (the 2.2 shell doesn't seem to catch it at all)

[ernie@eahimac ~]$ ./mongodb-osx-x86_64-2.2.5/bin/mongo --port 123123
MongoDB shell version: 2.2.5
connecting to: 127.0.0.1:123123/test
Wed Jul 17 17:12:19 getaddrinfo("127.0.0.1") failed: nodename nor servname provided, or not known
Wed Jul 17 17:12:19 Error: couldn't connect to server 127.0.0.1:123123 src/mongo/shell/mongo.js:93
exception: connect failed
[ernie@eahimac ~]$ ./mongodb-osx-x86_64-2.5.1/bin/mongo --port 123123
MongoDB shell version: 2.5.1
Wed Jul 17 17:12:29.804 Error: Invalid port number "123123" in connection string "127.0.0.1:123123/test" at src/mongo/shell/mongo.js:134
exception: connect failed
[ernie@eahimac ~]$



 Comments   
Comment by Daniel Pasette (Inactive) [ 26/Feb/14 ]

the bad port was fixed in SERVER-7808. in addition the entire command line and config file parsing system was refactored and has fixed the general issue.

Comment by Eric Daniels (Inactive) [ 24/Jul/13 ]

This applies to more than just --port. It appears any command processed in processCommandLineOptions() that calls dbexit() as a failure mechanism causes a stack trace to be printed. It is also somewhat misleading having the stack trace there because it detracts from the fact that the real error is printed on the first line of output.

Comment by Tad Marshall [ 18/Jul/13 ]

SERVER-8030 is the ticket that improved the shell's connection string validation (so an invalid port number is found and reported).

Generated at Thu Feb 08 03:22:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.