You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
We're using Mongoid 4.0.2, Moped 2.0.4, and Sidekiq 3.3.0. We made some changes to the pool size in our staging environment yesterday, and started getting emails from Compose (formerly MongoHQ) that we were flooding their instances with hundreds or thousands of authentications per minute. This baffled us because we'd been using larger pools in production for a long time and hadn't seen the same issue. Researching the problem led me to all the error reports from last year that were supposed to be fixed in Moped 2, so I was even more confused.
In both staging and production, we're declaring multiple sessions in our mongoid.yml because we have two different MongoDB databases to talk to. In production the two databases are on completely different hosts; in staging they were on the same instance and only the DB name was different:
Diving into the pooling behavior, I saw that in production, any queries on the second database would double the number of entries in the Moped::Connection::Manager pools hash. In staging, though, the number of pools stayed the same and only the DB name and credentials changed. It looks like this was because the pools hash is keyed by the hostname and port — so a connection to a different database on that same host-and-port will simply replace the entry in the hash.
This easily explains the "authentication flood" behavior we were seeing. Every time a query hit a different database than the one before, a new connection pool would replace the old one. It didn't happen in production because the pools pointed to different hosts and thus didn't replace each other.
We've found a workaround for this bug by simply moving our 'secondary' staging database to a different deployment in Compose. But being unable to stay connected to two sessions on the same host seemed like a moderately important problem, so I'm escalating it here. Please let me know if I can provide any additional information.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We're using Mongoid 4.0.2, Moped 2.0.4, and Sidekiq 3.3.0. We made some changes to the pool size in our staging environment yesterday, and started getting emails from Compose (formerly MongoHQ) that we were flooding their instances with hundreds or thousands of authentications per minute. This baffled us because we'd been using larger pools in production for a long time and hadn't seen the same issue. Researching the problem led me to all the error reports from last year that were supposed to be fixed in Moped 2, so I was even more confused.
In both staging and production, we're declaring multiple sessions in our mongoid.yml because we have two different MongoDB databases to talk to. In production the two databases are on completely different hosts; in staging they were on the same instance and only the DB name was different:
Diving into the pooling behavior, I saw that in production, any queries on the second database would double the number of entries in the Moped::Connection::Manager pools hash. In staging, though, the number of pools stayed the same and only the DB name and credentials changed. It looks like this was because the pools hash is keyed by the hostname and port — so a connection to a different database on that same host-and-port will simply replace the entry in the hash.
This easily explains the "authentication flood" behavior we were seeing. Every time a query hit a different database than the one before, a new connection pool would replace the old one. It didn't happen in production because the pools pointed to different hosts and thus didn't replace each other.
We've found a workaround for this bug by simply moving our 'secondary' staging database to a different deployment in Compose. But being unable to stay connected to two sessions on the same host seemed like a moderately important problem, so I'm escalating it here. Please let me know if I can provide any additional information.
The text was updated successfully, but these errors were encountered: