[SERVER-28560] Support specifying multiple mongos processes in the shell URI connection string Created: 20/Mar/17  Updated: 08/Jan/24  Resolved: 29/Jul/19

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

Type: Improvement Priority: Major - P3
Reporter: Enrique Garnelo Prediger Assignee: Backlog - Service Architecture
Resolution: Gone away Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-36173 connection string with multiple mongo... Closed
Related
is related to SERVER-6233 Support MongoDB URIs as mongo shell a... Closed
Assigned Teams:
Service Arch
Participants:
Case:

 Description   

The mongo shell should allow multiple mongos processes to be specified in a connection string URI, with the expectation that this would connect to the first available mongos process.

Drivers support this behaviour for the standard connection string URI format, but the mongo shell returns an unhelpful error message in MongoDB 3.4:

FailedToParse: Cannot list multiple servers in URL without 'replicaSet' option

The replicaSet option cannot be used with a mongos connection.

For now the only workaround I have is with a shell script and leveraging the 'echo $?' result to continue iterating through the list of available host:port of mongos processes.



 Comments   
Comment by Mira Carey [ 29/Jul/19 ]

It is worth noting that the mongo shell doesn't make any attempts to round-robin network requests over the multiple mongos processes in the connection string; the mongo shell only ever sends network requests to the first mongos process listed in the connection string.

I could be wrong, but I thought it was actually that we only send network requests to the first host we manage to connect to (and affix to it after that).

Closing this out as gone away, as the asked for functionality is present in 3.6 and later shells

Comment by Max Hirschhorn [ 30/Mar/18 ]

stennie, my understanding from having talked to mira.carey@mongodb.com about this in-person before is that this limitation was incidentally removed by the changes from 400b86d as part of SERVER-31061. In particular, the "Cannot list multiple servers in URL without 'replicaSet' option" error message was removed as part of those changes. It is worth noting that the mongo shell doesn't make any attempts to round-robin network requests over the multiple mongos processes in the connection string; the mongo shell only ever sends network requests to the first mongos process listed in the connection string.

Comment by Stennie Steneker (Inactive) [ 28/Mar/18 ]

This issue appears to be fixed in the 3.6 mongo shell. Tested using 3.6.3 and several likely variations:

mongo --host "localhost:27017,localhost:27018,localhost:27019"

mongo --host "mongodb://localhost:27017,localhost:27018,localhost:27019"

mongo "mongodb://localhost:27017,localhost:27018,localhost:27019"

Possibly related to improvements from sara.golemon (SERVER-28072 and related issues)?

The 3.4.14 shell fails to connect and exits with an unhelpful error message:

Error: Cannot list multiple servers in URL without 'replicaSet' option

The 3.2.19 shell doesn't exit, but appears to only be attempting to connect to the first host in the connection string.

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