[SERVER-10686] Selection of replicas in mongos not conforming to documentation Created: 05/Sep/13  Updated: 10/Dec/14  Resolved: 24/Jan/14

Status: Closed
Project: Core Server
Component/s: Internal Client, Sharding
Affects Version/s: 2.5.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Andre Spiegel Assignee: Randolph Tan
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-12284 ReplicaSetMonitor is broken Closed
Operating System: ALL
Participants:

 Description   

The mechanism in mongos to select a replica with secondary read preference does not do what the documentation says it does.

At http://docs.mongodb.org/manual/core/read-preference-mechanics/#member-selection it says that the algorithm takes the nearest replica (lowest ping time), and then computes a set of other replicas that are no further than the lowest ping time plus the value of --localThreshold. It then chooses one of these replicas at random.

Looking at the code in dbclient_rs.cpp, it takes --localThreshold as an absolute value and returns the first node that has a ping time less than that. If there is no such node, it returns a random node that matches the tags.

For comparison, I checked the Java driver and found that it implements what the documentation says.



 Comments   
Comment by Richard Kreuter (Inactive) [ 24/Jan/14 ]

Marking as duplicate per redbeard0531's direction.

Generated at Thu Feb 08 03:23:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.