Skip to content

postgres: lower tcp_keepalive connection settings#4027

Merged
danielnelson merged 1 commit intomainfrom
dbn/postgres-keepalive
Mar 19, 2026
Merged

postgres: lower tcp_keepalive connection settings#4027
danielnelson merged 1 commit intomainfrom
dbn/postgres-keepalive

Conversation

@danielnelson
Copy link
Copy Markdown
Contributor

@danielnelson danielnelson commented Mar 18, 2026

Description:

In some situations a half-open connections cannot be timed out using the idle_timeout, idle_in_transaction_session_timeout settings. In these cases, it is useful to have tcp_keepalive reduced to detect the error more quickly since the default is longer than 2 hours on most systems.

Changes to TestFencingCases to fix preexisting failure that is normally excluded by -tags nodb.

Workflow steps:

(How does one use this feature, and how has it changed)

Documentation links affected:

(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)

Notes for reviewers:

I was not able to duplicate this issue, but it has been reported in the wild on the server side. This doesn't add an new timeouts, so it ought to be safe. I didn't attempt to add this to source-postgres, because it didn't look like pgconn.ParseConfig supported these connection parameters, so perhaps we need another method there.

@danielnelson danielnelson force-pushed the dbn/postgres-keepalive branch from e79efbe to dda51cd Compare March 18, 2026 05:04
@danielnelson danielnelson requested review from a team and willdonnelly March 18, 2026 16:16
In some situations a half-open connections cannot be timed out using the
idle_timeout, idle_in_transaction_session_timeout settings.  In these
cases, it is useful to have tcp_keepalive reduced to detect the error
more quickly since the default is longer than 2 hours on most systems.
@danielnelson danielnelson force-pushed the dbn/postgres-keepalive branch from dda51cd to d413aba Compare March 18, 2026 16:20
Copy link
Copy Markdown
Contributor

@jacobmarble jacobmarble left a comment

Choose a reason for hiding this comment

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

Nice. Lots of tests. 👍

Copy link
Copy Markdown
Member

@willdonnelly willdonnelly left a comment

Choose a reason for hiding this comment

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

LGTM

We should probably figure out how to add this to source-postgres as well, AFAIK we don't currently set these params there either. (In a separate PR though, this one looks good as-is.)

@danielnelson danielnelson merged commit 5371276 into main Mar 19, 2026
67 of 69 checks passed
@danielnelson danielnelson deleted the dbn/postgres-keepalive branch March 19, 2026 16:32
@danielnelson danielnelson self-assigned this Mar 23, 2026
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