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

Changes from #with still bleed over

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 12_01_17
    • Affects Version/s: 2.1.0
    • Component/s: Public API
    • Labels:
      None
    • Environment:
      Mac OS X 10.10.4 running Ruby driver 2.1.0-beta against MongoDB 2.6.5

      Original issue was filed at https://github.com/mongoid/mongoid/issues/4097, it looks like https://github.com/mongodb/mongo-ruby-driver/commit/90525b13c65d512ea9528509243116c4dde78e1e was put in place for what I had filed but the issue still occurs. Here's a simple Mongoid spec you can paste in to illustrate the problem:

      Mongo::Logger.logger = Logger.new(STDOUT)
      default = Mongoid.client(:default)
      puts default.options
      Band.with(:write => {:w => 0}).collection.find({:_id => BSON::ObjectId.new}).update_one(:$set => {:foo => "bar"})
      default2 = Mongoid.client(:default)
      puts default2.options
      Band.collection.find({:_id => BSON::ObjectId.new}).update_one(:$set => {:baz => "qux"})
      

      produces logs:

      {:database=>"mongoid_test", :server_selection_timeout=>0.5, :max_pool_size=>1, :heartbeat_frequency=>180, :user=>"mongoid-user", :password=>"password", :auth_source=>"admin"}
      D, [2015-07-13T15:07:58.510872 #8189] DEBUG -- : MONGODB | 127.0.0.1:27017 | mongoid_test.update | STARTED | {:update=>"bands", :updates=>[{:q=>{:_id=><BSON::ObjectId:0x70103815604660 data=55a40c8e6a6f6e1ffd000000>}, :u=>{:$set=>{:foo=>"bar"}}, :multi=>false, :upsert=>false}], :writeConcern=>{:w=>0}, :ordered=>true}
      D, [2015-07-13T15:07:58.511738 #8189] DEBUG -- : MONGODB | 127.0.0.1:27017 | mongoid_test.update | SUCCEEDED | 0.000916s
      {:database=>:mongoid_test, :server_selection_timeout=>0.5, :max_pool_size=>1, :heartbeat_frequency=>180, :user=>"mongoid-user", :password=>"password", :auth_source=>"admin", :write=>{:w=>0}}
      D, [2015-07-13T15:07:58.511954 #8189] DEBUG -- : MONGODB | 127.0.0.1:27017 | mongoid_test.update | STARTED | {:update=>"bands", :updates=>[{:q=>{:_id=><BSON::ObjectId:0x70103848795240 data=55a40c8e6a6f6e1ffd000001>}, :u=>{:$set=>{:baz=>"qux"}}, :multi=>false, :upsert=>false}], :writeConcern=>{:w=>0}, :ordered=>true}
      D, [2015-07-13T15:07:58.512351 #8189] DEBUG -- : MONGODB | 127.0.0.1:27017 | mongoid_test.update | SUCCEEDED | 0.000413s
      

      You can see from the logs that the writeConcern of w:0 remains on the second query, and that repulling the client has its write concern affected and set to w:0.

            Assignee:
            durran.jordan@mongodb.com Durran Jordan
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: