[SERVER-30921] mongo cli --host argument regression from 3.2 to 3.4 Created: 01/Sep/17  Updated: 29/Jan/18  Resolved: 19/Sep/17

Status: Closed
Project: Core Server
Component/s: Shell, Tools
Affects Version/s: 3.4.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Queen Assignee: Sara Golemon
Resolution: Duplicate Votes: 2
Labels: mongo, shell, tools
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS release 6.7 (Final)


Issue Links:
Duplicate
duplicates SERVER-28072 Running a script using 'mongo' on rep... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

On 3.2.13

$ mongo --host mongo_cluster1/m1.localhost:27017,m2.localhost:27017 dbname
MongoDB shell version: 3.2.13
connecting to: mongo_cluster1/m1.localhost:27017,m2.localhost:27017/dbname

-
On 3.4.7

$ mongo --host mongo_cluster1/m1.localhost:27017,m2.localhost:27017 dbname
MongoDB shell version v3.4.7
connecting to: mongodb://mongo_cluster1/m1.localhost:27017,m2.localhost:27017/dbname
2017-09-01T16:25:00.225+0000 E QUERY    [thread1] Error: Failed to parse mongodb:// URL: mongodb://mongo_cluster1/m1.localhost:27017,m2.localhost:27017/dbname :
connect@src/mongo/shell/mongo.js:237:13

$ mongo dbname --host mongo_cluster1/m1.localhost:27017,m2.localhost:27017
// same error as above

$ mongo m1.localhost:27017,m2.localhost:27017/dbname
MongoDB shell version v3.4.7
connecting to: mongodb://m1.localhost:27017,m2.localhost:27017/dbname
2017-09-01T16:33:15.244+0000 E QUERY    [thread1] Error: Cannot list multiple servers in URL without 'replicaSet' option :
connect@src/mongo/shell/mongo.js:237:13

-
Undocumented workaround #1 on 3.4.7, also works on 3.2.13

$ mongo mongodb://m1.localhost:27017,m2.localhost:27017/dbname?replicaSet=mongo_cluster1
MongoDB shell version v3.4.7
connecting to: mongodb://m1.localhost:27017,m2.localhost:27017/dbname?replicaSet=mongo_cluster1

-
Undocumented workaround #2 on 3.4.7, errors on 3.2.13

$ mongo m1.localhost:27017,m2.localhost:27017/dbname?replicaSet=mongo_cluster1
MongoDB shell version v3.4.7
connecting to: mongodb://m1.localhost:27017,m2.localhost:27017/dbname?replicaSet=mongo_cluster1

Participants:

 Description   

When using the --host argument on 3.4.7, you can no longer connect to a replica set while also specifying a database name.



 Comments   
Comment by Sara Golemon [ 19/Sep/17 ]

You're not the first to notice this. I happen to have a fix waiting on test runs which should hopefully land soonish. Once it's on master we'll start the backport process to get it onto 3.4.

Keep an eye on SERVER-28072 for updates.

Comment by Aaron Queen [ 01/Sep/17 ]

I found one more difference where something worked in 3.2.13, but errors in 3.4.7

$ mongo 192.168.0.1
MongoDB shell version: 3.2.13
connecting to: 192.168.0.1/test

$ mongo 192.168.0.1/dbname
MongoDB shell version: 3.2.13
connecting to: 192.168.0.1/dbname

$ mongo --host 192.168.0.1 dbname
MongoDB shell version: 3.2.13
connecting to: 192.168.0.1:27017/dbname

$ mongo 192.168.0.1
MongoDB shell version v3.4.7
connecting to: mongodb://127.0.0.1:27017/192.168.0.1
2017-09-01T17:49:38.216+0000 E QUERY    [thread1] Error: Failed to parse mongodb:// URL: mongodb://127.0.0.1:27017/192.168.0.1 :
connect@src/mongo/shell/mongo.js:237:13

$ mongo 192.168.0.1/dbname
MongoDB shell version v3.4.7
connecting to: mongodb://192.168.0.1/dbname

$ mongo --host 192.168.0.1 dbname
MongoDB shell version v3.4.7
connecting to: mongodb://192.168.0.1:27017/dbname

Comment by Kelsey Schubert [ 01/Sep/17 ]

Hi aqueen,

Thanks for reporting this behavior. We're investigating and will update this ticket when we know more.

Kind regards,
Thomas

Generated at Thu Feb 08 04:25:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.