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

ReplSetConnection does not correctly discover new master after a disconnect

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 1.5.1
    • 1.5.2
    • None

    Description

      I performed the following sequence of operations:

      • Connected to a 3-node replica set using 1.5.1:

      >> m = Mongo::ReplSetConnection.new(['127.0.0.1', 6001], ['127.0.0.1', 6002], ['127.0.0.1', 6003]); m.primary
      => ["qa-dev1.stripe.com", 6002]

      • Did an rs.stepDown() on the master
      • On the next request, as expected, an error was raised:

      >> m['test']['tar'].insert({}, :safe => true)
      Mongo::ConnectionFailure: Operation failed with the following exception: Connection reset by peer
      from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.1/lib/../lib/mongo/networking.rb:312:in `receive_message_on_socket'
      from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.1/lib/../lib/mongo/networking.rb:169:in `receive_header'

      from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.1/lib/../lib/mongo/collection.rb:944:in `insert_documents'
      ...

      • On the next request, it appears the connection is trying to write to the wrong node:

      >> m['test']['tar'].insert({}, :safe => true)
      Mongo::OperationFailure: 10058: not master
      from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.1/lib/../lib/mongo/networking.rb:82:in `send_message_with_safe_check'
      from /usr/lib/ruby/gems/1.8/gems/mongo-1.5.1/lib/../lib/mongo/collection.rb:946:in `insert_documents'

      • Indeed, the primary hasn't updated:

      >> m.primary
      => ["qa-dev1.stripe.com", 6002]

      Attachments

        Issue Links

          Activity

            People

              kbanker Kyle Banker
              gdb Greg Brockman
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: