[SERVER-22043] count helper doesn't apply read preference Created: 03/Jan/16  Updated: 21/Nov/16  Resolved: 04/Jan/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 3.2.0
Fix Version/s: 3.2.6, 3.3.0

Type: Bug Priority: Major - P3
Reporter: Hoyt Ren Assignee: Adam Midvidy
Resolution: Done Votes: 0
Labels: test-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian 7


Issue Links:
Related
related to SERVER-23427 Add test to ensure that read-only ope... Closed
Backwards Compatibility: Fully Compatible
Operating System: Linux
Backport Completed:
Steps To Reproduce:

mongo XXX.XXX.XXX.XXX:XXXX
db.getMongo().setReadPref('secondary');
use XXXX;
db.getMongo().setReadPref('secondary');
db.XXX.find().count();

Participants:

 Description   

I setup a v3.2 mongos with 3 shards and 3 replica for each shard.

But from shell, no matter I set readpref to 'secondary' or 'secondarypreferred', my query always go to primary.

I haven't tried other api like java, etc.

By the way, when I miss-spell the mode, it doesn't tell me an error.



 Comments   
Comment by Githook User [ 19/Apr/16 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-22043 attach read preference in count helper

(cherry picked from commit a7820c6af9c4474239f8f80c88d9de7722fa900a)
Branch: v3.2
https://github.com/mongodb/mongo/commit/a43b64811a0ce3edc798c18612a91e2460a6414c

Comment by Githook User [ 04/Jan/16 ]

Author:

{u'username': u'amidvidy', u'name': u'Adam Midvidy', u'email': u'amidvidy@gmail.com'}

Message: SERVER-22043 attach read preference in count helper
Branch: master
https://github.com/mongodb/mongo/commit/a7820c6af9c4474239f8f80c88d9de7722fa900a

Comment by Randolph Tan [ 04/Jan/16 ]

Ran into this while writing tests. It looks like the problem was that the count helper was calling runCommand instead of runReadCommand:

https://github.com/mongodb/mongo/blob/r3.2.0/src/mongo/shell/query.js#L357

Generated at Thu Feb 08 03:59:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.