when mongodb is io busy, multiGet from mongos catch a cursor timed out (timeout: 1000, time left: 0:0, status: 0).
then , php-cgi reconnect mongos. but old connection hasn't been closed.
in my test, i multiGet 10000 keys from mongo, and set timeout to be 1ms. so this will always be timed out.
and each time php-cgi will create new connection , with old connection never be closed;
after long time , mongos have too many connections.
i check the php driver code, and found that
driver called util/connect.c mongo_util_disconnect function to close connections. First, check server->owner with getpid().
but in my case, server->owner always be 0, and the connection can't be closed;
i found server is get from connecto poll(stack_monitor).
server->connected = 1;
server->socket = node->socket;
only socket is set, and owner hasn't been set. so owner will be 0, and can't be closed;
i add "server->owner = getpid();" in this function , and now it works.
Can this modify cause any other error ??