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

Collection read preference not passed to find command

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.10.0.rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      A read preference set with #with does not appear to be passed to the find command:

      irb(main):006:0> c=a['test']
      => #<Mongo::Collection:0x47405477702640 namespace=admin.test>
      irb(main):007:0> c.read_preference
      => {"mode"=>:secondary}
      irb(main):008:0> d=c.with(read:{mode: :primary})
      => #<Mongo::Collection:0x47405477816800 namespace=admin.test>
      irb(main):009:0> d.read_preference
      => {:mode=>:primary}
      irb(main):010:0> d.find.to_a.count
      ...
      D, [2019-06-24T18:00:36.726737 #21320] DEBUG -- : MONGODB | localhost:27741 | admin.find | STARTED | {"find"=>"test", "filter"=>{}, "$readPreference"=>{"mode"=>"secondary"}, "lsid"=>{"id"=><BSON::Binary:0x47405477895640 type=uuid data=0x67aab09b8aa14b73...>}}
      

      Note that the find command still had a secondary read preference even though I verified that the collection's read preference is primary.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: