Skip to content

Add support for tcp_user_timeout #503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 12, 2023

Conversation

drdrsh
Copy link
Collaborator

@drdrsh drdrsh commented Jul 12, 2023

TCP_USER_TIMEOUT is a quite powerful tool for managing TCP timeouts. It is a bit complex in how it behaves but it is currently the only real way for controlling the number of retransmits an active socket makes before giving up and timing out. Without this parameter set on the socket, we fallback to the OS default tcp_retries2 parameter which generally keeps retrying for about 15 minutes before declaring the connection dead.

using TCP_USER_TIMEOUT with keepalive parameter ensures that we detect bad connections early and clean them up before we exhaust our pools and lock up the proxy.

Docs:
https://man7.org/linux/man-pages/man7/tcp.7.html
https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/
https://tech.instacart.com/the-vanishing-thread-and-postgresql-tcp-connection-parameters-93afc0e1208c

@drdrsh drdrsh marked this pull request as ready for review July 12, 2023 18:23
@levkk
Copy link
Contributor

levkk commented Jul 12, 2023

It would be good to make it optional (leave default as not configured), but can be done as follow up if deemed necessary.

@levkk levkk merged commit 3c9565d into postgresml:main Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants