Selection of replicas in mongos not conforming to documentation

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.5.2
    • Component/s: Internal Client, Sharding
    • None
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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.

              Assignee:
              Randolph Tan
              Reporter:
              Andre Spiegel
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: