Skip to content

Enable SO_KEEPALIVE and SO_LINGER on JRT TCP connections#36060

Open
papa99do wants to merge 2 commits intovespa-engine:masterfrom
marqo-ai:fix/jrt-tcp-socket-options
Open

Enable SO_KEEPALIVE and SO_LINGER on JRT TCP connections#36060
papa99do wants to merge 2 commits intovespa-engine:masterfrom
marqo-ai:fix/jrt-tcp-socket-options

Conversation

@papa99do
Copy link
Contributor

Summary

  • Enable SO_KEEPALIVE on JRT TCP connections for dead peer detection via OS-level keepalive probes
  • Enable SO_LINGER with timeout 0 for immediate connection teardown (RST instead of TIME_WAIT) when closing stale connections

These options help detect and clean up stale TCP connections faster, particularly useful during rolling upgrades when config servers restart and existing connections may become half-open.

Changes

Single file change in jrt/src/com/yahoo/jrt/Connection.java:

  • socket.channel().socket().setKeepAlive(true) — enables TCP keepalive probes
  • socket.channel().socket().setSoLinger(true, 0) — enables immediate teardown on close

Background

This is part of a larger effort to address stale TCP connections blocking file distribution downloads (split from #35932 per reviewer feedback). The socket options are the smallest, most independent piece.

papa99do and others added 2 commits February 28, 2026 14:19
Enable TCP keepalive probes and linger-on-close for JRT connections
to improve detection and cleanup of dead peers during rolling upgrades.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
return ((socket != null) && (socket.channel() != null));
}

SocketChannel socketChannel() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

visible for unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants