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

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

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.9.0
    • Component/s: Server Selection
    • None
    • Environment:
      Development

      This is in reference to https://jira.mongodb.org/browse/RUBY-1281 ticket. I have added the db configuration and what error I think prevails.
       
      I am trying to upgrade the mongo gem from 2.4.3 to 2.9.0. In the process, when I try to use a replica set, I am getting an issue in writing to the database. The reads are however fine.
       
      When going through the code for server selection in selectable.rb, the select_server action, I see that select(cluster.servers) action call returns an empty array in case of selecting a server to write to.
       
      My database configuration is:
       
      {
        "default"=>
            {
               "database"=>"test_database",
               "hosts"=>["localhost:27018", "localhost:27019", "localhost:27020"],
               "options"=>{
                      "read"=>

      {                       "mode"=>:secondary_preferred                  }

      ,
                       "max_pool_size"=>1,
                       "connect"=>:replica_set,
                       "replica_set"=>"rs0",
                       "platform"=>"mongoid-6.2.1"
               }
           }
      }

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            palakrajeshchaudhary@gmail.com Palak Chaudhary
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: