[CSHARP-264] Remove connect option from connection string Created: 08/Jul/11 Updated: 11/Mar/19 Resolved: 06/Apr/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 1.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Major Change |
| Description |
|
No other driver supports the connect=mode option on the connect string, so we think it should be removed from the C# driver. The driver must still know what connection mode to use (direct or replicaset), but this will now be implied by the other options. If there is more than one host or if the replicaset=name option is present then the driver will connect to a replica set. Otherwise it will connect directly to a single server. What is lost is the ability to specify a list of hosts with connect=direct and have the driver try the servers in order until it finds one it can connect to. You can duplicate this behavior in your own code by trying a sequence of single host connection strings yourself. This change is scheduled for some future release to allow sufficient time for comments. |
| Comments |
| Comment by Craig Wilson [ 08/Sep/12 ] |
|
I believe we still need to keep this option as we don't do auto discovery when only 1 server is listed so that clients can connect directly to a replica set member. Hence, we still need to connect in order to support listing a single server on the connection string and force the driver to connect as if its a replica set. |
| Comment by Robert Stam [ 10/Jul/12 ] |
|
There will be support in 1.6 for automatic discovery of the type of servers being connected to. Automatic discovery will be done when the connection mode is: connect=automatic which is now the default if the connection string doesn't have a value for connect. The decision whether to actually remove the connect option from the connection string is being postponed to 2.0, and one possibility is that we will decide to leave it in. |
| Comment by Robert Stam [ 15/Jun/12 ] |
|
It's currently scheduled for 1.6. |
| Comment by Grégoire Seux [ 15/Jun/12 ] |
|
Any progress on this feature ? |
| Comment by Grégoire Seux [ 16/Dec/11 ] |
|
This solution is perfect for my usage. |
| Comment by Robert Stam [ 15/Dec/11 ] |
|
One proposal is this: 1. If the connection string only contains a single server then the driver will always connect directly to that server and no other. 2. If the connection string contains two or more servers then the driver will automatically detect whether they are replica set members or mongos's. If they are replica set members standard replica set connection conventions are used. If they are mongos's one of them will be chosen and the rest are available for failover. If they are standalone mongod's the driver should probably raise an error (what's the point of connecting to a random standalone database?). So basically the driver would do the right thing automatically. There are a couple of edge cases that might behave differently but they are probably not common |
| Comment by Grégoire Seux [ 15/Dec/11 ] |
|
And what is their way to support connection failover on mongos ? The java driver seems to have droppend the support : https://jira.mongodb.org/browse/JAVA-338 |
| Comment by Robert Stam [ 15/Dec/11 ] |
|
The C# driver also defaults to replica set connection mode when more than one server is provided in the connection string. The connect=direct mode is used to override the default, thus telling the driver that the multiple servers are not a replica set seed list but instead are a list of single instance servers to try one at a time until a successful connection is made (the multiple servers in the connect=direct mode presumably either be mongos's or single server mongod's). I would like to keep the connect=direct feature, but there is pressure from other driver teams to remove it because other drivers don't support it. |
| Comment by Grégoire Seux [ 15/Dec/11 ] |
|
Mongos as a single point of failure would discourage to use the driver (as it is) for production service. For now we can use it, but I may have to build a wrapper around MongoServer class to handle (re)connection to several mongos. |
| Comment by Craig Wilson [ 15/Dec/11 ] |
|
I believe the other drivers make an assumption: If there is more than one server provided in the connection string, it uses replica set mode. Otherwise, it uses single server mode. |
| Comment by Robert Stam [ 17/Nov/11 ] |
|
Thanks for your comments. Still not sure exactly what we will end up doing regarding this option on the connect string. In any case there won't be any changes in the next release so there is still time for others to comment as well. |
| Comment by Grégoire Seux [ 17/Nov/11 ] |
|
Is there any idea on how we can handle the automatic failover between mongos if this connection=direct is removed ? This would make the mongos a single point of failure and would create the need for the users to use a system of exception handling to be able to connect to another mongos if the one provided is unreachable. |
| Comment by Grégoire Seux [ 18/Oct/11 ] |
|
This feature is important to us : it allow to have automatic failover on mongos. This avoid to have a single point of failure. I can understand that the connect=mode option is not the best option. Maybe the driver could try to connect to any instance of the server list provided and understand if this part of a replicaset or a mongos. This allow to remove the option while preserving this nice feature. |
| Comment by Robert Stam [ 18/Oct/11 ] |
|
Instead of voting on this issue, please comment. That way it will be clear if you want connect=mode kept or removed, and why. |