Problem with connection to db , queries hang. Reverting to mongoose 4.6.6 solves it
Mongoose 4.7.7
Do you want to request a feature or report a bug? I want to report a bug
What is the current behavior? All request towards the db just hang and do not return anything
If the current behavior is a bug, please provide the steps to reproduce.
const ODconnection = mongoose.createConnection(config.mongo.uri, config.mongo.options);
ODconnection.on('error', err => {
logger.error(err);
});
module.exports.ODconnection = ODconnection;
var connection = require('../../config/connections').ODconnection;
var ProgramSchema = new mongoose.Schema({...});
connection.model('Program', ProgramSchema);
All queries hang and return nothing
Program.find() will just hang
Fixed if I downgrade to [email protected] The change in 4.7.7 is a dependency version update [email protected] to [email protected]. I am guessing that is was is causing the issue
Please mention your node.js, mongoose and MongoDB version. mongoose 4.7.7 node 6.9.2 MongoDB 3.2.3
What does your URI look like? Please make sure you remove any sensitive info. The big change in muri 1.2.0 was passing username and password through decodeURIComponent
This is also happening to me.
Happening to me as well. Maybe you meant switching to 4.7.6 @dariiiannn?
My URI is something like:
mongodb://admin:[email protected]:27017,circolo-production-shard-00-01-qpdcn.mongodb.net:27017,circolo-production-shard-00-02-qpdcn.mongodb.net:27017/circolo?ssl=true&replicaSet=Circolo-Production-shard-0&authSource=admin
What happens is that the server hangs when connecting to the database. Rolling back to 4.7.6 makes it work.
@gfzabarino does your password have any non-alphanumeric characters, like %?
No, just alphanumerical characters.
Confirmed, we have the same issue, after upgraded to 4.7.7, server pm2 process will be 100% CPU usage:

we are trying to trace this with strace on our server, step by step to positioning this problem, and finally confirmed caused by mongoose, this is the system call status when this happening, very like an infinite loop:

we are using MongoDB HA mode with replica set failover, the connection URI like:
mongodb://***:****@ze1a3dbb36ef5642.xxx.net:3717,ze1a3dbb36ef5641.xxx.net:3717/admin?replicaSet=mgset-1405217
after we go back to 4.6.6, thanks @dariiiannn :

@dariiiannn @sonicgao May I ask the reason of why you went back to 4.6.6? Doesn't it work for you with 4.7.6?
@gfzabarino maybe they were upgrading from 4.6.6.
At our team, we have the same issue: 4.7.7 causes high CPU and increased RAM usage. After having downgraded to 4.7.6 the problem is solved.
Yes, that was my experience as well.
Unfortunately we can't reproduce it (yet) by running tests locally, only after deploying our service to our staging environment.
@sonicgao same problem here getting same results, actually i noticed that the app freezes after 2 hours even on high cpu instances
@gfzabarino 4.7.6 working well, the only broken version here is the latest.
Another point is the process is not completely not working, it's working but very slow until cpu to 100%, then the process died.
I've just tried to reproduce the problem by setting the version directly to the commits between the release 4.7.6 and the 4.7.7. The first version that produced the error was commit chore: upgrade mongodb -> 2.2.18 (f47260b002c4accc6f2b77b8042012d352c81618). I was able to temporarily fix it by clicking on Reset Dependency Cache on CodeShip. Our service started to work again, but the next commit (chore: actually bump to 2.2.19, e4fb16cdf0abd5b847df0b8979d019c64c5c86a9) caused error again. This time Reset Dependency Cache couldn't help it.
The used Node version is 6.9.1.
Maybe related to https://github.com/christkv/mongodb-core/issues/156, i think mongodb 2.2.22 fixes it, well apparantly not entirely. Indeed it's related to mongodb >=2.2.17 in combo with replication
mongoose = 4.7.8, still have this issue
@gfzabarino sorry for the late reply, we reverted to that because if was the latest version that previously worked for us.
Connection string looks like mongodb://user:[email protected]:27017,xxx.xxx.com,xxx2.xxx.com,xxx3.xxx.com/db-dev?replicaSet=rs0
Like many already pointed out, both 4.7.8 and 4.7.7 have this problem, while 4.7.6 does not.
For us, the hanging was not always reproducible. After restarting the application, we observed like a 60% chance it would hang all reads and writes to DB from that point on. In the fraction that worked, the process would hit 100% CPU after some time.
We tested both against MongoDB 3.2.11 and 3.4.1
It seems to be a mongodb driver bug 🐞
[email protected] uses [email protected] while [email protected] uses [email protected].
Forcing [email protected] to downgrade to [email protected] fixes the problem for me.
This JIRA issue seems to be related: https://jira.mongodb.org/browse/NODE-917, but I'm not totally positive.