Shard server monitoring frequency in java driver

48 views
Skip to first unread message

Umesh Deshpande

unread,
Mar 17, 2017, 7:12:47 PM3/17/17
to mongodb-user
Hi,

I have a mongos process, which connects to shard servers (3) in a replica set. I want to increase the shard server monitoring frequency, so that the app/client can quickly detect the availability of a new primary, when the original primary fails. Which options should I set to accomplish this? I'm using a java driver and I tried the following settings, though it didn't help. Pymongo has a connectTimeoutMS option for this, it seems that java driver doesn't provide that.

        MongoClientOptions.Builder build = MongoClientOptions.builder();
        build.heartbeatFrequency(500);
        build.heartbeatConnectTimeout(500);
        build.heartbeatSocketTimeout(500);
        MongoClientURI uri = new MongoClientURI(url, build);

Thanks,
Umesh

Umesh Deshpande

unread,
Mar 21, 2017, 4:03:00 AM3/21/17
to mongodb-user
From replica set, with rs.status(), I can see that the failover is complete and the new primary's healthy status is 1, but somehow the client write requests fail. Is the mongos still not aware that the new primary has been elected?

Umesh Deshpande

unread,
Mar 21, 2017, 7:52:22 PM3/21/17
to mongodb-user
Looks like mongos tries to connect to the failed primary, even after a new primary is elected. It keeps printing the following message. Is there a way to make it give up sooner?
NETWORK  [conn46] Failed to connect to host1:27018, in(checking socket for error after poll), reason: Connection refused
...

Wan Bachtiar

unread,
May 28, 2017, 11:44:03 PM5/28/17
to mongodb-user

Pymongo has a connectTimeoutMS option for this, it seems that java driver doesn’t provide that.

Hi Umesh,

Have you found the solution for this ?

In MongoDB Java Driver 3.4, the MongoClientURI class supports connection configuration for connectTimeoutMS. This configuration will determine how long a connection can take to be opened before timing out.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages