[JAVA-1160] Driver can't connect to a member of an un-initiated replica set Created: 07/Apr/14  Updated: 30/Jan/15  Resolved: 28/Apr/14

Status: Closed
Project: Java Driver
Component/s: Cluster Management
Affects Version/s: 2.12.0
Fix Version/s: 2.12.1, 3.0.0

Type: Bug Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Start mongod like:

mongod --replSet test

and try to send a command:

        MongoClient mongo = new MongoClient(new MongoClientURI("mongodb://localhost:27001"));
        CommandResult result = mongo.getDB("admin").command("ping");

It fails with this exception:

Exception in thread "main" com.mongodb.MongoServerSelectionException: Unable to connect to any servers

The root cause is that ClusterDescription.getAny() only returns server descriptions where isPrimary || isSecondary is true.



 Comments   
Comment by Githook User [ 30/Jan/15 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1160: ClusterDescription.getAny now returns any ok server, not just primaries and secondaries. A new method, getAnyPrimaryOrSecondary, has been added for server selectors that will only talk to primaries or secondaries.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/70ecbe840199c3e3e8765b0fe92352f55c911e4b

Comment by Githook User [ 01/Aug/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1160: ClusterDescription.getAny now returns any ok server, not just primaries and secondaries. A new method, getAnyPrimaryOrSecondary, has been added for server selectors that will only talk to primaries or secondaries.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/cd8f98b31ddcb08cb962d467bbbdfa115845ffde

Comment by Jeffrey Yemin [ 29/Apr/14 ]

Closing for 2.12.1 release.

Comment by Githook User [ 28/Apr/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1160: ClusterDescription.getAny now returns any ok server, not just primaries and secondaries. A new method, getAnyPrimaryOrSecondary, has been added for server selectors that will only talk to primaries or secondaries.
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/70ecbe840199c3e3e8765b0fe92352f55c911e4b

Comment by Githook User [ 08/Apr/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1160: ClusterDescription.getAny now returns any ok server, not just primaries and secondaries. A new method, getAnyPrimaryOrSecondary, has been added for server selectors that will only talk to primaries or secondaries.
Branch: 2.12.x
https://github.com/mongodb/mongo-java-driver/commit/cd8f98b31ddcb08cb962d467bbbdfa115845ffde

Generated at Thu Feb 08 08:53:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.