Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-5707

Aggregate with writes may unnecessarily override read prefs

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.28.1, 1.29.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • C Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      When doing an aggregate operation with a write stage ($out/$merge), the server selection spec notes:

      If there are one or more available servers and one or more of those servers is pre-5.0 (i.e. wire version < 13), drivers MUST NOT use the available read preference and MUST instead select a server using a primary read preference.

      Otherwise, if there are either no available servers, all available servers are 5.0+ (i.e. wire version >= 13), or the topology type is LoadBalanced (we can assume the backing mongos is 5.0+), drivers MUST use the available read preference.

      However the C driver appears to check if any servers are pre-5.0. This includes unavailable servers, which have ServerType=Unknown and maxWireVersion=0. As a result, if there are not-yet discovered servers, the read preference may be overridden unexpectedly.

      Background

      This was discovered during implementation of CDRIVER-5706. Using pooled clients for the test "Aggregate with $out includes read preference for 5.0+ server" is more likely to have Unknown servers. Single-threaded clients scan all servers before the first operation. Pooled clients can send operations as soon as there is an eligible server.

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: