[JAVA-708] ReadPreference.nearest() does not count primary in expected way Created: 05/Dec/12 Updated: 19/Mar/13 Resolved: 25/Feb/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Cluster Management |
| Affects Version/s: | 2.10.0 |
| Fix Version/s: | 2.11.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | piotrs | 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, Mongodb 2.2 |
||
| Issue Links: |
|
||||||||
| Description |
|
My configuration is very simple, I've two servers A[primary] and B[secondary] geographically distributed with ~120 ms ping distance. Both A and B runs application with ReadPreference.nearest(). Is it expected behaviour? |
| Comments |
| Comment by auto [ 08/Feb/13 ] | |||||||||||||||||||||||||||||||||||||
|
Author: {u'date': u'2013-01-07T16:34:34Z', u'email': u'jeff.yemin@10gen.com', u'name': u'Jeff Yemin'}Message: | |||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 17/Dec/12 ] | |||||||||||||||||||||||||||||||||||||
|
I found the bug. It's in com.mongodb.ReplicaSetStatus.ReplicaSet#calculateBestPingTime. Primaries are being ignored when calculating the best ping time. | |||||||||||||||||||||||||||||||||||||
| Comment by piotrs [ 07/Dec/12 ] | |||||||||||||||||||||||||||||||||||||
|
Thank you for your anser, it's good to know it is not an expected behaviour. Below some debug information. I change hosts name into A and B
A mongo status from A: {replSetName: rs, members: [ { address:'A:27017', ok:true, ping:0.515565, isMaster:true, isSecondary:false, setName:rs, maxBsonObjectSize:16777216, }, { address:'/B:27017', ok:true, ping:267.9882, isMaster:false, isSecondary:true, setName:rs, maxBsonObjectSize:16777216, } ], and this status doesn't change over time. A mongo status from B:
To remind: both applications on A and B has ReadPreference.nearest(). But I see queries from application A on mongo server on B, it's some fraction of all queries. I don't see queries from application B on A server however, which is expected. I'd be happy to provide additional information if it might help. If it is needed I can provide information about ReadPreference per collection and data from A and B:28017 pages. | |||||||||||||||||||||||||||||||||||||
| Comment by Jeffrey Yemin [ 05/Dec/12 ] | |||||||||||||||||||||||||||||||||||||
|
That's definitely not the intention. Can you periodically print the ReplicaSetStatus on all your app servers, like:
It will tell us what the driver sees as the current state of the world. |