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

@config nil in Mongo::Node when secondary? called

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.8.1
    • Affects Version/s: None
    • Component/s: Replica Set
    • None

      I've just changed my app to use the ReplSetConnection vs the regular Connection, and I'm using a post 1.7.0 build (git master 9bc8495e2d4868be22e27c384a616f8bdec8d551).

      I've noticed my log files are littered with the following, at seemingly random intervals:

      [2012-10-30T03:51:42Z] ERROR – vines: Thread pool operation failed: undefined method `[]' for nil:NilClass
      [2012-10-30T03:51:42Z] DEBUG – vines: /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/util/node.rb:117:in `secondary?'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/util/pool.rb:93:in `matches_mode'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/util/pool_manager.rb:110:in `read_pool'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/repl_set_connection.rb:412:in `read_pool'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/repl_set_connection.rb:342:in `block in checkout_reader'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/repl_set_connection.rb:325:in `checkout'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/repl_set_connection.rb:341:in `checkout_reader'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/cursor.rb:552:in `checkout_socket_from_connection'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/cursor.rb:487:in `block in send_initial_query'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/util/logging.rb:32:in `instrument'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/cursor.rb:483:in `send_initial_query'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/cursor.rb:468:in `refresh'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/cursor.rb:129:in `next'
      /home/ec2-user/.gem/ruby/1.9.1/bundler/gems/mongo-ruby-driver-804e605bf49f/lib/mongo/collection.rb:303:in `find_one'

      My app is threaded (I'm using eventmachine and all mongo operations are wrapped in deferrables), so this stack trace leads to be believe there's a race condition causing @config to be nil when secondary? is called.

      I can't reproduce this in my dev env, it only seems to happen under the load of production.

      ReplSetConnection:
      opts = {
      :pool_timeout => 5,
      :pool_size => 5,
      :op_timeout => 10,
      :ssl => false,
      :connect => true,
      :refresh_mode => :sync
      }

      Server: 2.0.7
      Config:
      {
      "_id" : "rs0",
      "version" : 121314,
      "members" : [

      { "_id" : 1, "host" : "AAA:27017", "priority" : 0, "hidden" : true }

      ,

      { "_id" : 4, "host" : "BBB:27017", "priority" : 0, "hidden" : true }

      ,

      { "_id" : 9, "host" : "CCC:27017" }

      ,

      { "_id" : 10, "host" : "DDD:27017", "priority" : 0 }

      ]
      }

      Also, my RS requires auth, if that changes anything.

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            jonson Jon DeYoung
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: