Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-563

readPreferred option in URI causes all queries to fail

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8.4
    • Affects Version/s: 1.8.3
    • Component/s: None
    • None

      According to the connection string documentation at http://docs.mongodb.org/manual/reference/connection-string/#uri.readPreference one should be able to add ?readPreference=secondary and send all reads to secondaries, all writes to primary.

      When adding this to a connection string and connecting to a secondary, it seems to still attempt to query the master:

      /home/doug/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/mongo-1.8.3/lib/mongo/db.rb:535:in `command': Database command 'count' failed: (errmsg: 'not master'; note: 'from execCommand'; ok: '0.0'). (Mongo::OperationFailure)
      	from /home/doug/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/mongo-1.8.3/lib/mongo/cursor.rb:172:in `count'
      	from /home/doug/.rbenv/versions/1.9.3-p327/lib/ruby/gems/1.9.1/gems/mongo-1.8.3/lib/mongo/collection.rb:957:in `count'
      

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            dougtmayer Doug Mayer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: