Skip to content
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

[pg-gateway] Set server-fin timeout #847

Merged
merged 2 commits into from
Jul 11, 2019
Merged

[pg-gateway] Set server-fin timeout #847

merged 2 commits into from
Jul 11, 2019

Conversation

stevendanna
Copy link
Contributor

When a go process dies because of a signal or a panic, defer'd
database closes may not execute. In this case, HAProxy will keep the
client side connection in CLOSE-WAIT and the server-side connection in
ESTAB. Setting server-fin times out the server-side connection
quickly, avoiding a leaked process. Without this, the process would
not close for 5 minutes until the tunnel timeout is hit.

Signed-off-by: Steven Danna steve@chef.io

When a go process dies because of a signal or a panic, defer'd
database closes may not execute. In this case, HAProxy will keep the
client side connection in CLOSE-WAIT and the server-side connection in
ESTAB. Setting `server-fin` times out the server-side connection
quickly, avoiding a leaked process. Without this, the process would
not close for 5 minutes until the tunnel timeout is hit.

Signed-off-by: Steven Danna <steve@chef.io>
# a service is failing in a loop, this can quickly lead to the
# exhaustion of available ports.
#
# This number was chosen with very little thought.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

I can't think of a compelling reason to keep these connections around
any longer than we need to since the postgresql shutdown procedure is:

> The normal, graceful termination procedure is that the frontend
  sends a Terminate message and immediately closes the connection. On
  receipt of this message, the backend closes the connection and
  terminates.

So the server is expecting an immediate close from the client once it
has sent a Terminate and the server doesn't typically send a
response.

Signed-off-by: Steven Danna <steve@chef.io>
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.

3 participants