Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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