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

Socket IOError after Primary member restarts and becomes Primary again

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.2.6
    • Affects Version/s: 2.2.5
    • Component/s: Replica Set
    • None
    • Environment:
      Ubuntu 12.04 - 16.04 64bit, MongoDB 3.2.0 - 3.2.7, SSL enabled, plain authentication enabled

      After upgrade to MongoDB from v3.0.7 to v3.2.6 started encountering Mongo::Error::SocketError: IOError. After some research found that happened each time when primary member in replicaset was restarted and elected as primary again.
      Was reproduced with:

      client = Mongo::Client.new(
        [
          "127.0.0.1:27017",
          "127.0.0.1:27018",
          "127.0.0.1:27019"
        ],
        :ssl => true,
        :ssl_verifyi => false,
        :ssl_cert => "/tmp/mongodb/ssl/client.crt",
        :ssl_key => "/tmp/mongodb/ssl/client.key",
        :ssl_ca_cert => "/tmp/mongodb/ssl/mongodb.pem",
        :read => { :mode => :primary },
        :write => { :w => 2 },
        :database => "test",
        :auth_source => "admin",
        :user => "user",
        :password => "password"
      )
      client = client.use("test")
      client[:users].insert_one(name: "John")
      #stop primary member, wait for another member to be elected as primary
      client[:users].insert_one(name: "Paul")
      #start ex-primary and wait for this member to be elected as primary again
      client[:users].find(name: "John").count
      

      And we are getting this error each time:

      Failure/Error: expect(@client[:users].find(name: "John").count).to eq 1
      Mongo::Error::SocketError:
        IOError
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/socket.rb:195:in `rescue in handle_errors'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/socket.rb:190:in `handle_errors'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/socket.rb:122:in `read'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/protocol/message.rb:113:in `deserialize'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connectable.rb:107:in `block in read'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connectable.rb:91:in `ensure_connected'
      # /home/deply/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connectable.rb:106:in `read'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connection.rb:158:in `deliver'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connection.rb:104:in `block in dispatch'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/monitoring/publishable.rb:47:in `publish_command'
      # /home/deploy/.rvm/gems/ruby-2.3.0/gems/mongo-2.2.5/lib/mongo/server/connection.rb:103:in `dispatch'
      ...
      

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            pbondarenko Pavel Bondarenko
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: