[SERVER-29341] Set TCP_KEEPIDLE and TCP_KEEPINTVL (or OS equivalent) whenever available Created: 23/May/17  Updated: 30/Oct/23  Resolved: 01/Sep/17

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: 3.5.13

Type: Improvement Priority: Major - P3
Reporter: Bernie Hackett Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to DRIVERS-383 Enable and configure TCP Keepalive by... Closed
is related to SERVER-29359 Enable SO_KEEPALIVE on egress server ... Closed
Backwards Compatibility: Minor Change
Sprint: Platforms 2017-09-11
Participants:

 Description   

The server currently enables SO_KEEPALIVE on sockets whenever it is defined. On Linux it goes the extra mile and attempts to set a reasonable value for TCP_KEEPIDLE and TCP_KEEPINTVL (the default TCP_KEEPIDLE value on Linux - and keep-alive timeout on Windows - is a completely useless 7200 seconds).

The server should attempt to set a reasonable value for TCP_KEEPIDLE and TCP_KEEPINTVL whenever they are defined, not just on Linux. It should also attempt to set the equivalent values on Windows using WSAIoctl.

References:
https://github.com/mongodb/mongo/blob/master/src/mongo/util/net/sock.cpp#L153-L193
http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/#setsockopt
https://msdn.microsoft.com/en-us/library/windows/desktop/dd877220(v=vs.85).aspx



 Comments   
Comment by Githook User [ 28/Jun/18 ]

Author:

{'username': 'sgolemon', 'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com'}

Message: SERVER-29341 Set KeepAlive params on windows and mac

(cherry picked from commit bd153cba11ab82ffbf8d2bc0b801eb808369eb9e)
Branch: v3.4
https://github.com/mongodb/mongo/commit/b5dcbd7a26a8452de61a79dc40e9c569e9344d24

Comment by Sara Golemon [ 01/Sep/17 ]

KeepAlive parameters are now updated on Windows and Mac according to the same rules as Linux.

That is, if the current keepidle/keepintvl values are greater than 300 seconds, they are reduced to 300 seconds. If they are shorter than 300s they are not modified.

Note that while windows and linux have two distinct settings, mac uses a single setting.

Comment by Githook User [ 01/Sep/17 ]

Author:

{'username': 'sgolemon', 'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com'}

Message: SERVER-29341 Set KeepAlive params on windows and mac
Branch: master
https://github.com/mongodb/mongo/commit/bd153cba11ab82ffbf8d2bc0b801eb808369eb9e

Comment by Shane Harvey [ 24/Jul/17 ]

The server's current behavior on Linux is to only set keep-alive times if the default value is greater than a threshold. On Windows, it may be more complicated to have the same behavior.

It's simple to set the keep-alive times using WSAIoctl with SIO_KEEPALIVE_VALS but it does not seem possible to read the current SIO_KEEPALIVE_VALS on a socket; the WSAIoctl output buffer is not used according to the documentation and confirmed by testing locally.

So I believe the only way to get the default keep-alive times are by reading the KeepAliveTime and KeepAliveInterval registry entries.

Comment by Bernie Hackett [ 26/May/17 ]

The argument here isn't to configure more tcp options, but to apply the values we already configure on a wider array of operating systems.

Comment by Mira Carey [ 26/May/17 ]

It's not clear to me if we want to do this. We've made a conscious choice in the past to do application level heartbeating wherever feasible, partially because relying more strongly on tcp keep alives may make alternate transports more difficult to reason about.

acm, what are your thoughts?

Generated at Thu Feb 08 04:20:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.