Connection to mongo server is hanging out

2,151 views
Skip to first unread message

prashant gupta

unread,
Sep 11, 2012, 6:15:55 AM9/11/12
to mongod...@googlegroups.com
Hello,

I am use mongo db 2.0.2 on 64 bit RHEL. Due to nfs file system, data directory is has been corrupted.
Mongo server process is running smoothely.

When I try to connect using mongo client, it hangs out for around 8-9 minutes . No matter whether I pass correct or incorrect password -

./mongo localhost:27017/admin -uadmin -p
MongoDB shell version: 2.0.2
Enter password:
connecting to: localhost:27017/admin

After hang out is over, it throws following exception -

connecting to: localhost:27017/admin
Mon Sep 10 23:16:58 Socket recv() errno:104 Connection reset by peer 127.0.0.1:27017
Mon Sep 10 23:16:58 SocketException: remote: 127.0.0.1:27017 error: 9001 socket exception [1] server [127.0.0.1:27017]
Mon Sep 10 23:16:58 DBClientCursor::init call() failed
Mon Sep 10 23:16:58 Error: Error during mongo startup. :: caused by :: DBClientBase::findN: transport error: localhost:27017 query: { whatsmyuri: 1 } shell/mongo.js:86
exception: connect failed

Can I prevent this hang out ? How can I set connection time out and socket time out ?

Thanks in advance. Let me know if you need more info.

Switching to coding part -

I want exception to be thrown after 10 seconds, if the connection is not establised -

            MongoOptions options = new MongoOptions()
            options.connectTimeout=10000
            options.socketTimeout=10000

            options.connectionsPerHost = 50

            mongo = new Mongo(getReplicaSetServerAddresses(), options)

            after this code I do authenticate the mongo db. But the exception is not being thrown after 10 seconds.

Regards,
Prashant Gupta

prashant gupta

unread,
Sep 11, 2012, 9:55:32 AM9/11/12
to mongod...@googlegroups.com
Correcting one statement that mongo process is not running smoothely. ps -ef | grep mongo also hangs on. netstat on 27017 shows CLOSE_WAIT.

Thanks,
Prashant

David Hows

unread,
Sep 13, 2012, 1:25:07 AM9/13/12
to mongod...@googlegroups.com
Hi Prashant,

Are you saying that the ps -ef | grep mongo also takes quite a long time to execute?

Cheers,

David

prashant gupta

unread,
Sep 13, 2012, 1:42:37 AM9/13/12
to mongod...@googlegroups.com

It hangs out for a long time. and did not get executed

David Hows

unread,
Sep 13, 2012, 2:07:31 AM9/13/12
to mongod...@googlegroups.com
Hi Prashant,

If thats the case then it sounds like your system is heavily taxed. Being unable to execute a process stack query is a sign of a much bigger issue.

Does top show any performance issues?

Cheers,

David

prashant gupta

unread,
Sep 13, 2012, 3:07:33 AM9/13/12
to mongod...@googlegroups.com
My question is not why mongo server process is hanging out. .My question is that .. When I connect to mongo server in this situation via java api or shell. it hangs out and throws exception after approx 8-9 minutes.
I want this exception should be thrown immediately. How can I achieve this?

David Hows

unread,
Sep 13, 2012, 7:41:03 PM9/13/12
to mongod...@googlegroups.com
Prashant,

There are a number of things which could cause this issue. The connection timeout / socket timeout only govern the timeout in the event of the socket / connection to the server becoming unavailable. They will not govern things such as load issues or a cursor timeout.

Given that you mentioned that "ps -ef" is taking a long time to execute, so it sounds as if your server is under a heavy load. If this is the case then it would explain why your connections are taking a number of minutes to timeout - the connection itself is fine, but the server is unable to gather enough resources to perform any queries.

You can confirm your servers load issue by executing "uptime". It should provide you with a load average. Can you post the output so i can have a look?

Cheers,

David
Reply all
Reply to author
Forward
0 new messages