Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-10686

Selection of replicas in mongos not conforming to documentation

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

      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@mongodb.com Randolph Tan
            Reporter:
            andre.spiegel@mongodb.com Andre Spiegel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: