-
Type: Sub-task
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
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.
- backported by
-
NODE-5983 [v5.x BACKPORT] Read preference not applied to commands properly
- Backlog