[JAVA-1246] If two instances of the same standalone server is passed to MongoClient, the driver removes it from the cluster monitor Created: 14/May/14 Updated: 30/Jan/15 Resolved: 16/Jun/14 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Cluster Management |
| Affects Version/s: | 2.12.1 |
| Fix Version/s: | 2.12.3, 3.0.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Damien Raude-Morvan | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Java 1.7 |
||
| Description |
|
Hi, I've just upgraded our dev. environnement from Mongo Java Driver 2.11.4 to 2.12.1 and I'm getting the following error at each startup of our application :
FYI, I'm using MongoClient(List<ServerAddress> seeds, MongoClientOptions options) constructor so that's my ClusterConnectionMode is "Multiple".
Going deeper into Mongo Java driver code, I've found that my *ClusterSettings* hosts attribute, contains duplicate values : I can find twice "localhost:27017" ! It seems that hosts should be a Set instead of List. Regards, |
| 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: | ||||||||
| 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: | ||||||||
| Comment by Githook User [ 16/Jun/14 ] | ||||||||
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: | ||||||||
| Comment by Githook User [ 16/Jun/14 ] | ||||||||
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: | ||||||||
| Comment by Jeffrey Yemin [ 14/May/14 ] | ||||||||
|
I changed priority to Minor since there is an easy workaround. | ||||||||
| Comment by Jeffrey Yemin [ 14/May/14 ] | ||||||||
|
Never mind, you're totally right. I re-opened this issue. | ||||||||
| Comment by Damien Raude-Morvan [ 14/May/14 ] | ||||||||
|
I perfectly understand that you want to keep public API as-is (ie. with a List<ServerAddress>), that's not my point. I was only suggesting to use a Set as internal storage instead of a List. I'll open a separate issue for this feature request for requesting that the MongoClient constructor check for duplicates.. | ||||||||
| Comment by Jeffrey Yemin [ 14/May/14 ] | ||||||||
|
We can't change the public API to be a Set, as that would break binary compatibility. If you'd like, you can report another issue requesting that the MongoClient constructor check for duplicates. Regardless, the message that is being logged is harmless. | ||||||||
| Comment by Damien Raude-Morvan [ 14/May/14 ] | ||||||||
|
Hi, I took some time to review my issue and you're right : my application had a corner case in its configurable handling which might send *same server address* multiple times on MongoClient constructor. So here is a snippet of code that will create trigger the "Expecting a single StandAlone, but found more than one" exception :
Finally, I think that the main issue - which is not really that critical - is that MongoClient doesn't enforce ServerAddress equals/hashCode contract by using a Set to store them. Regards, | ||||||||
| Comment by Jeffrey Yemin [ 14/May/14 ] | ||||||||
|
I'm not able to reproduce this. I wrote a test program creating a MongoClient like this:
where the server running on 27017 is a standalone. I confirmed that ClusterSettings.hosts contains just single ServerAddress and did not observe the log message that you did. Can you confirm that you're doing the same thing, in particular that your application is not passing more than one ServerAddress to the MongoClient constructor? |