-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.3
-
Component/s: None
-
Environment:
-
Empty show more show less
Context: replset with 3 nodes; connecting to it using all default parameters.
Problem: after replset master re-election or a rs.reconfig() command, I see in mongodb logs that the client reconnects whole connection pool (5 conns) every 30 seconds.
I tracked the source of the problem to the _reconnect_servers function in /connection/repl_set/ha.js file. When it runs, new connection pool is established, with 'socketTimeoutMS' parameter set to 30000. Unlike in HighAvailabilityProcess.prototype.start function above, the db linked to connection is not queried every haInterval (default 2 seconds), so the connection is idle and timed out after 30 seconds, which triggers a reconnect.
So, I would suggest to either set socketTimeoutMS=0 in the aforementioned function, or provide an app-level keepalive functionality like with the haInterval (TCP-level keepAlive will not work, as it doesn't reset the timer).