MongoDB "Connection failed. Operation in progress"

strange behavior appeared yesterday:

with a small load, all requests take a lot of time, and then the Msgstr site return error "Connection to MongoDB failed. On the mongostat we see about 10-30 connections (very few, because we usually work with 400-500) But when I print" netstat -na | grep 27017 ", I see a very large number of TCP connections (> 150):

http://pastebin.com/3ghtwkVd

Why does mongodb close the connection but TCP is still open?

We do not use persistent connections and always do Mongo: close () at the end of scripts.

The site works in a cloud system such as Amazon EC2 (we do not observe any network problems)

10.1.1.16 - MongoDB 10.1.1.7 - Apache 1 Gb / s between servers OS: Debian 6 Squeeze MongoDB: 1.8.2 (since 1.6.6 we have the same problem) Apache 2 PHP 5.3.6 PHP mongo driver 1.1.0 ( pooling in 1.2.x is very bad for us)

+4
source share
1 answer

It looks like your driver (e.g. PHP) doesn't actually close the TCP connection, even when you close it using the method.

If you use PHP as a module, try gracefully reloading apache so that the PHP module is loaded and reloaded. Thus, destructors are called and connections are closed.

If you use PHP as a fastcgi application, restart it (kill / exec) and run it again.

Report an error if necessary.

0
source

All Articles