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

Mongo::Error::NoServerAvailable: No server is available matching preference: #<Mongo::ServerSelector::Primary

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5.0
    • Component/s: Replica Set
    • None
    • Environment:
      Debian 3.16.51-3+deb8u1 (2018-01-08) x86_64 GNU/Linux

      Failing to write to database only in a replica set configuration, read is working fine. Also works fine in 2.4.3. Looks life failing to select the primary instance.

      Full stack trace

      {{2.4.2 :006 > client[:contacts].insert_one(

      { vpa: 'cool@cool'}

      )
      Mongo::Error::NoServerAvailable: No server is available matching preference: #<Mongo::ServerSelector::Primary:0x14987080 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/server_selector/selectable.rb:115:in `select_server'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/cluster.rb:246:in `next_primary'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/retryable.rb:150:in `legacy_write_with_retry'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/retryable.rb:103:in `write_with_retry'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/collection.rb:422:in `block in insert_one'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/client.rb:485:in `with_session'
      from /usr/local/rvm/gems/ruby-2.4.2/gems/mongo-2.5.0/lib/mongo/collection.rb:421:in `insert_one'
      from (irb):6
      from /usr/local/rvm/rubies/ruby-2.4.2/bin/irb:11:in `<main>'
      2.4.2 :007 > exit}}

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            deepakkumarnd@gmail.com Deepak Kumar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: