mongoose icon indicating copy to clipboard operation
mongoose copied to clipboard

Problem with connection to db , queries hang. Reverting to mongoose 4.6.6 solves it

Open DarianRusu opened this issue 9 years ago • 30 comments

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

DarianRusu avatar Jan 17 '17 14:01 DarianRusu

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

vkarpov15 avatar Jan 18 '17 23:01 vkarpov15

This is also happening to me.

actionnick avatar Jan 19 '17 01:01 actionnick

Happening to me as well. Maybe you meant switching to 4.7.6 @dariiiannn?

gfzabarino avatar Jan 21 '17 00:01 gfzabarino

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 avatar Jan 21 '17 00:01 gfzabarino

@gfzabarino does your password have any non-alphanumeric characters, like %?

vkarpov15 avatar Jan 21 '17 02:01 vkarpov15

No, just alphanumerical characters.

gfzabarino avatar Jan 21 '17 02:01 gfzabarino

Confirmed, we have the same issue, after upgraded to 4.7.7, server pm2 process will be 100% CPU usage: screen shot 2017-01-22 at 09 17 18

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: screen shot 2017-01-21 at 16 51 57

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 : screen shot 2017-01-22 at 09 30 05

gacyun avatar Jan 22 '17 01:01 gacyun

@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 avatar Jan 23 '17 20:01 gfzabarino

@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.

szenti avatar Jan 23 '17 21:01 szenti

Yes, that was my experience as well.

gfzabarino avatar Jan 23 '17 21:01 gfzabarino

Unfortunately we can't reproduce it (yet) by running tests locally, only after deploying our service to our staging environment.

szenti avatar Jan 23 '17 21:01 szenti

@sonicgao same problem here getting same results, actually i noticed that the app freezes after 2 hours even on high cpu instances

jrsalgado avatar Jan 24 '17 01:01 jrsalgado

@gfzabarino 4.7.6 working well, the only broken version here is the latest.

gacyun avatar Jan 24 '17 02:01 gacyun

Another point is the process is not completely not working, it's working but very slow until cpu to 100%, then the process died.

gacyun avatar Jan 24 '17 02:01 gacyun

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.

szenti avatar Jan 24 '17 08:01 szenti

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

tommarien avatar Jan 24 '17 14:01 tommarien

mongoose = 4.7.8, still have this issue

jrsalgado avatar Jan 24 '17 18:01 jrsalgado

@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

DarianRusu avatar Jan 25 '17 09:01 DarianRusu

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

sitegui avatar Jan 26 '17 18:01 sitegui

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.

sitegui avatar Jan 26 '17 19:01 sitegui