Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4285

New connection is being every query I execute

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 5.1.0
    • Component/s: None
    • Labels:
      None

      Every time I query a Mongo document a new authentication is being created. I'm doing this from my rails console.

      For example: Search.count

      Returns:

      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.getnonce | STARTED | {}
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.getnonce | SUCCEEDED | 0.001041145s
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.authenticate | STARTED | {}
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.authenticate | SUCCEEDED | 0.000993972s
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.count | STARTED | {"count"=>"mongo_searches", "query"=>{}}
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.getnonce | STARTED | {}
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.getnonce | SUCCEEDED | 0.001196958s
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.authenticate | STARTED | {}
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.authenticate | SUCCEEDED | 0.001096091s
      MONGODB | ds051371-a0.mongolab.com:51371 | myapp.count | SUCCEEDED | 0.006626804s

      My configuration is:

      production:

      1. Configure available database clients. (required)
        clients:
      2. Defines the default client. (required)
        default:
        uri: <%= ENV['MONGOLAB_URI'] %>
        options:
      3. max_retries specifies the number of times to attempt an
      4. operation before giving up.
        max_retries: 5
      1. retry_interval specifies the number of seconds to wait before
      2. http://blog.mongolab.com/2014/02/mongodb-driver-tips-tricks-mongoid-3/
        retry_interval: 30
      1. The time in seconds before Moped will timeout connection and node
      2. operations. (default 5)
        timeout: 15
      1. The maximum number of connections in the connection pool. (default: 5)
        max_pool_size: 20
      1. Configure Mongoid specific options. (optional)
        options:
      2. Raise an error when performing a #find and the document is not found.
      3. (default: true)
        raise_not_found_error: true

      I'm using Mongodb 2.6.8 and Mongoid 5.1.

      Mongoid 5.1 should use a connection pool but it seems this is not happening. Any idea why?

        1. Gemfile.lock.txt
          15 kB
        2. mongoid.yml
          3 kB

            Assignee:
            Unassigned Unassigned
            Reporter:
            e3matheus Elías
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: