-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 5.7.0
-
Component/s: Cluster Management
-
None
-
Java Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Currently, when the Java driver connects to a replica set, it automatically discovers and manages cluster topology by adding and removing hosts based on information reported by replica set members (via ensureServers).
This behavior is not always desirable. Use cases where users may want to disable this:
- Some nodes in the replica set are known to be unreachable from the client
- The client should only connect to the explicitly specified seed list, without auto-discovery
Proposal: Add a new boolean connection string option onlyConnectOriginalUrl (default: false).
When set to true, the driver will:
- Still perform necessary validity checks (server type check, replica set name matching) - Skip the ensureServers() call in handleReplicaSetMemberChanged, meaning no new hosts will be added and no existing hosts will be removed based on topology discovery reports
Usage example: mongodb://host1:27017,host2:27018/?replicaSet=myRS&onlyConnectOriginalUrl=true
Implementation:
- ConnectionString.java: parse the new option
- ClusterSettings.java: store and expose the flag via builder and getter
- AbstractMultiServerCluster.java: apply the guard logic in handleReplicaSetMemberChanged