Operational Defect Database

BugZero found this defect 2562 days ago.

MongoDB | 355212

[SERVER-28043] mongos does not obey readPreference for queries over views

Last update date:


Affected products:

MongoDB Server

Affected releases:


Fixed releases:

No fixed releases provided.



When mongos rewrites a query over a view as a query over the view's backing collection, it discards the readPreference. The result is that reads over views will always target the primary node of all involved shards, even if the application specified a read preference such as "secondary" or "secondaryPreferred". Note that mongos will always forward a query over a view to the primary shard in order to obtain the view definition, since it does not currently store view catalog information. This initial query will respect the readPreference. It is only as mongos rewrites the query given the view definition that we erroneously discard the server selection metadata.

Top User Comments

james.wahlin@10gen.com commented on Wed, 5 Apr 2017 17:53:47 +0000: A fix for this issue was delivered under SERVER-28040. james.wahlin@10gen.com commented on Wed, 8 Mar 2017 20:29:25 +0000: I suspect readConcern is being discarded as well on mongos rewrite. Will confirm and fix under this ticket if it is the case.

Additional Resources / Links


BugZero Risk Score

Coming soon



Have you been affected by this bug?


Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.


Login to read and write comments.

Have you ever...

had your data corrupted from a