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

New client created every time when using Model.with(collection: "...")

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 5.0.1
    • Affects Version/s: 5.0.0
    • Component/s: None
    • Labels:
      None

      After finding this bug report https://jira.mongodb.org/browse/MONGOID-4127 I was able to track down an issue with Mongoid, where every time I was using the "with" modifier and changing only the collection, I ended up with a new client and eventually too many connections to the MongoDB server, resulting in IOErrors.

      In that ticket Durran Jordan mentions that when changing options other than collection, database, client, read or write it should spawn a new client. However I'm changing only "collection" options and still I get a new client, and the "MONGODB | Adding 127.0.0.1:27017 to the cluster." line to the log.

      I'm using Rails 4.2.2 and Mongoid 5.0.0.

      Additionally, how can we close/disconnect the newly created client in case we need to change other options in the "with" command, or until the issue is fixed.
      Mongoid.disconnect_clients or GeoName.collection.client.close don't seem to work, they only close the original connection before the "with".

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            clarkgr George L
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: