From the MongoDB documentation:
secondaryPreferred
In most situations, operations read from secondary members, but in situations where the set consists of a single primary (and no other members), the read operation will use the set’s primary.
When the read preference includes a tag set, the client attempts to find a secondary member that matches the specified tag set and directs reads to a random secondary from among the nearest group. If no secondaries have matching tags, the client ignores tags and reads from the primary.
Read operations using the secondaryPreferred mode may return stale data.
My guess is that you would get the data from S2
, since that is what you have asked for with the preferred suffix. The secondary
option excludes the primary entirely but while the secondaryPreferred
allows for primary to be used in case of no secondaries.
Though by using tags for your servers in the same data center you can make the driver read from primary even though a secondary is present in the rest of the replica set.