Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5817 Read preference not applied to commands properly
  3. NODE-5981

Implement 6.x: Read preference not applied to commands properly

    • Type: Icon: Sub-task Sub-task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 6.5.0
    • Affects Version/s: None
    • Component/s: None
    • 0
    • Not Needed
    • v5.x
    • Hide

      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.

      Show
      Create a copy of the Kickoff Template with the issue key (NODE-XXX) in the filename and share a link to the new doc via this field.
    • 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?

      Add $readPrefernce to commands according to spec: https://github.com/mongodb/specifications/blob/5de9d45528a07d51579253f57f7ba23dbbaa68d1/source/server-selection/server-selection.md#topology-type-single

      Topology type: Single

      A deployment of topology type Single contains only a single server of any type. Topology type Single signifies a direct connection intended to receive all read and write operations.

      Therefore, read preference is ignored during server selection with topology type Single. The single server is always suitable for reads if it is available. Depending on server type, the read preference is communicated to the server differently:

      • Type Mongos: the read preference is sent to the server using the rules for Passing read preference to mongos and load balancers.
      • Type Standalone: clients MUST NOT send the read preference to the server
      • For all other types, using OP_QUERY: clients MUST always set the SecondaryOk wire protocol flag on reads to ensure that any server type can handle the request.
      • For all other types, using OP_MSG: If no read preference is configured by the application, or if the application read preference is Primary, then $readPreference MUST be set to { "mode": "primaryPreferred" } to ensure that any server type can handle the request. If the application read preference is set otherwise, $readPreference MUST be set following Document structure.

      The single server is always suitable for write operations if it is available.

            Assignee:
            alena.khineika@mongodb.com Alena Khineika
            Reporter:
            alena.khineika@mongodb.com Alena Khineika
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: