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

Mongo.setReadPref(“secondary”) doesn't work when connected to primary node

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.8, 3.2.1
    • Component/s: Shell
    • None
    • ALL
    • Hide

      As stated in the description..

      Show
      As stated in the description..

      I'm not sure if I got this wrong, but I expect Mongo.setReadPref("secondary") to force reads to get redirected to the secondary nodes of a replica set. If I'm connected to the master of the set via mongo-shell, the shell should know about primary/secondary nodes. Problem is that if I query something (which is of course a read) the master handles my query, which is not what I want it to do (because I do some reporting stuff).

      I also tried to set the readPref for single find(...) calls (with db.collection.find(

      {email: "example@mail.com"}

      ).readPref("secondary")), which didn't work neither.

      If I connect to the secondary right away (when starting the mongo shell), this works as expected. The problem still exists, since I don't want to care to which server I connect (in case of primary/secondary node changes). Mongo drivers in python e.g. do support this.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            robsi Robert Aistleitner
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: