Priority: Major - P3
Resolution: Won't Fix
Affects Version/s: 1.5.5
Fix Version/s: None
Environment:Clients: Ubuntu 14.04 / Mac OSX, PHP-FPM 5.4 / 5.5
Server: Ubuntu 14.04, Mongo 2.6.4
Last comment by Customer:true
We upgraded servers from 2.4.x to 2.6.4 and this issue came up.
We have MongoCursor::$timeout=20000 in our scripts. Unfortunately some queries do sometimes take that long and are then killed. This worked fine until upgrade. After upgrade the server does not close these connections and they are left in state CLOSE_WAIT. The server gradually becomes unresponsive and has to be restarted. Also if the client stops sending requests, the connections are closed (noticed this when trying to reproduce the situation in testing). Here is a simple script I used to reproduce this error:
MongoCursor::$timeout = 100;
$mc = new MongoClient("mongodb://test-server");
$coll = $db->test->collection;
$reg = new MongoRegex("/^Text/i");
$it = $coll->find(array("textfield"=> $reg));
I then used siege (or ab) to stress this script with 10 concurrent connections. mongostat showed open connections on the server side going up from 18 to 1140 Performing other queries while this was going on (without the timeout) was also impossible.
We also tried setting $timeout to -1 in production, but we then hit PHPs max_execution_time which eventually caused the same affect.