Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4092

Mongoid is blocked when mongo server restart

    • Type: Icon: Task Task
    • Resolution: Done
    • 5.0.0
    • Affects Version/s: None
    • Component/s: None
    • None

      Mongoid is totally blocked when server restarts.
      Looks like timeout option is not working.

      # Gemfile
      gem 'mongoid', github: "mongoid/mongoid", branch: "master"
      
       
      #mongo_test.rb
      require 'mongoid'
      class Product
        include Mongoid::Document
        field :name,  type: String
      end
      
      Mongoid.load! "mongoid.yml", :development
      Product.destroy_all
      Product.create(name: "Mongo test")
      
      while true
        print Product.all.first.name
        sleep 1
      end
      
      #mongoid.yml
      development: 
        clients: 
          default: 
            uri: "mongodb://localhost/mongo_test"
            options: 
              read: 
                mode: :primary
              server_selection_timeout: 10
              socket_timeout: 5
      

      When mongo server restart, code just blocked, not reconnects, no errors.

      Stacktrace on break:

      , [2015-06-08T13:13:54.522779 #31341] DEBUG -- : MONGODB | QUERY | namespace=mongo_test.products selector={} flags=[] limit=0 skip=0 project=nil | runtime: 158644.8395ms
      D, [2015-06-08T13:13:54.523294 #31341] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 151666.8334ms
      /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/socket.rb:161:in `read': Interrupt
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/socket.rb:161:in `read_from_socket'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/socket.rb:126:in `block in read'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/socket.rb:173:in `handle_errors'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/socket.rb:123:in `read'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/protocol/serializers.rb:62:in `deserialize'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/protocol/message.rb:193:in `deserialize_header'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/protocol/message.rb:83:in `deserialize'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connectable.rb:110:in `block in read'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connectable.rb:95:in `ensure_connected'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connectable.rb:110:in `read'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connectable.rb:67:in `block in dispatch'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/loggable.rb:44:in `log'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/loggable.rb:65:in `log_debug'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connectable.rb:65:in `dispatch'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/operation/read/query.rb:61:in `block in execute_message'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/connection_pool.rb:99:in `with_connection'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/server/context.rb:63:in `with_connection'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/operation/read/query.rb:60:in `execute_message'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/operation/read/query.rb:54:in `execute'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/collection/view.rb:164:in `send_initial_query'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/mongo-2.0.4/lib/mongo/collection/view/iterable.rb:39:in `each'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/query_cache.rb:207:in `each'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/contextual/mongo.rb:240:in `first'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/contextual/mongo.rb:240:in `block in first'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/contextual/mongo.rb:489:in `try_cache'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/contextual/mongo.rb:239:in `first'
      	from /home/vagrant/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/bundler/gems/mongoid-2f806d1d38b4/lib/mongoid/contextual.rb:20:in `first'
      	from ./mongo_test.rb:12:in `<main>'
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            rkyrychuk rkyrychuk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: