Skip to content

netx: add SetTCPUserTimeout to drop dead TCP connections fast - #2

Merged
nicopernas merged 1 commit into
mainfrom
nico/netx-tcp-user-timeout
Oct 7, 2026
Merged

nicopernas merged 1 commit into
mainfrom
nico/netx-tcp-user-timeout

Conversation

@nicopernas

Copy link
Copy Markdown
Collaborator

When a peer disappears without closing the connection (e.g. its node
loses its network), Linux retries unacknowledged data for ~15 min
(tcp_retries2) before the call fails. SetTCPUserTimeout sets
TCP_USER_TIMEOUT so the kernel drops the connection after the given
time instead. Linux only; a no-op elsewhere. Meant for pgx's
AfterNetConnect hook in the services that talk to Postgres.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

When a peer disappears without closing the connection (e.g. its node
loses its network), Linux retries unacknowledged data for ~15 min
(tcp_retries2) before the call fails. SetTCPUserTimeout sets
TCP_USER_TIMEOUT so the kernel drops the connection after the given
time instead. Linux only; a no-op elsewhere. Meant for pgx's
AfterNetConnect hook in the services that talk to Postgres.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nicopernas
nicopernas merged commit 1503e40 into main Oct 7, 2026
4 checks passed
@nicopernas
nicopernas deleted the nico/netx-tcp-user-timeout branch October 7, 2026 12:42
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.

1 participant