Nodejs Driver : Timeout of one connection causes multiple timeouts

39 views
Skip to first unread message

sac...@litmusworld.com

unread,
Jul 17, 2017, 10:42:19 AM7/17/17
to mongodb-user
Hi,

I was observing a pattern with one of our applications which seems to be a bug. So wanted to check if anybody else has seen this behavior and has overcome this problem. If yes, wanted to understand how to workaround. 

In one of our NodeJS application, we use MongoDB Native NodeJs driver (2.2.22). We use the connection pool concept built into the driver, by connecting once (connect) and then reusing the created client while performing our queries. (similar to https://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html#mongoclient-connection-pooling)

We have not set any values for connectTimeoutMS. So the default is being used.

Some of our find/sort queries take a long time to complete, these error out with a connection timeout. That behavior is understandable. 
But during that same instant of time, we observe other faster queries also fail with a timeout. This happens only during that same instant of time. 

So it looks like the connection which has timedout is re-used and is causing a failure. Is this something which has been observed by anybody? Any way of working around this problem? Should any clean up be performed if a connection timeout occurs before the connection is put into the available pool. 

Kevin Adistambha

unread,
Aug 6, 2017, 8:57:42 PM8/6/17
to mongodb-user

Hi Sachin,

But during that same instant of time, we observe other faster queries also fail with a timeout. This happens only during that same instant of time.

It’s been a while since you posted this issue. Have you found a solution yet?

The behaviour you described is curious indeed. It sounds like the whole connection pool timed out due to a timeout on a single query. Could you provide more details:

  • What is your MongoDB version and your OS version
  • What error message (from node and from the mongod logs) you observed?
  • Could you provide a small example script that can reproduce this behaviour reliably?
  • The latest MongoDB node driver is version 2.2.30. Are you seeing the same issue in the current version, or only on 2.2.22?

Best regards,
Kevin

Reply all
Reply to author
Forward
0 new messages