Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-22043

count helper doesn't apply read preference

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.2.0
    • Fix Version/s: 3.2.6, 3.3.0
    • Component/s: Shell
    • Labels:
    • Environment:
      Debian 7
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      Linux
    • Backport Completed:
    • Steps To Reproduce:
      Hide

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

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

      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.

        Issue Links

          Activity

          Hide
          renctan Randolph Tan added a comment - - edited

          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

          Show
          renctan Randolph Tan added a comment - - edited 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
          Hide
          xgen-internal-githook Githook User added a comment -

          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

          Show
          xgen-internal-githook Githook User added a comment - 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
          Hide
          xgen-internal-githook Githook User added a comment -

          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

          Show
          xgen-internal-githook Githook User added a comment - 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

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: