Skip to content

Support bookie server config tcp keep-alive#4762

Merged
wenbingshen merged 3 commits intoapache:masterfrom
wolfstudy:support-bk-server-config-tcp-keepalive
Apr 28, 2026
Merged

Support bookie server config tcp keep-alive#4762
wenbingshen merged 3 commits intoapache:masterfrom
wolfstudy:support-bk-server-config-tcp-keepalive

Conversation

@wolfstudy
Copy link
Copy Markdown
Member

Motivation

In PR #4683, we introduced support for configuring TCP keep-alive parameters (TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_KEEPCNT) on the Bookie client side (PerChannelBookieClient). This allowed users to fine-tune keep-alive behavior per connection instead of relying solely on the kernel-level defaults defined in /proc/sys/net/ipv4/tcp_keepalive_*.

However, as discussed in apache/pulsar#25580, a one-sided configuration is not enough. TCP keep-alive is a per-socket setting that works independently on each end of a connection. If only the client enables custom keep-alive parameters while the server still uses the OS-level defaults, operators are still forced to tune the kernel parameters of the host on which the Bookie runs in order to achieve a consistent end-to-end keep-alive behavior. This defeats the purpose of having fine-grained, application-level control and makes it cumbersome to deploy Bookies in environments where modifying OS-wide TCP settings is not permitted (e.g., shared or managed hosts).

To close this gap, we need to provide the same configurability on the Bookie server side (BookieNettyServer), so that a complete, symmetric TCP keep-alive configuration can be achieved from BookKeeper itself, without requiring any changes to the underlying operating system.

Changes

  • ServerConfiguration: added serverTcpKeepIdle / serverTcpKeepIntvl / serverTcpKeepCnt, all defaulting to -1 (meaning "use OS default").
  • BookieNettyServer: applies the new options via EpollChannelOption.TCP_KEEPIDLE / TCP_KEEPINTVL / TCP_KEEPCNT when the event loop is EpollEventLoopGroup, and only when the value is > 0. For Nio / IoUring / Default event loops, behavior falls back to the original SO_KEEPALIVE — fully backward compatible.

Backward Compatibility

All new options default to -1 and Epoll-specific channel options are only applied on EpollEventLoopGroup. Existing deployments see no behavior change after upgrading.

References

Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Copy link
Copy Markdown
Member

@wenbingshen wenbingshen left a comment

Choose a reason for hiding this comment

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

LGTM

@wenbingshen wenbingshen requested a review from lhotari April 28, 2026 08:45
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
Signed-off-by: xiaolongran <xiaolongran@tencent.com>
@wolfstudy
Copy link
Copy Markdown
Member Author

@lhotari @wenbingshen PTAL again, thanks

Copy link
Copy Markdown
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@wolfstudy
Copy link
Copy Markdown
Member Author

wolfstudy commented Apr 28, 2026

rerun failure checks

@wenbingshen wenbingshen merged commit a61a630 into apache:master Apr 28, 2026
34 of 36 checks passed
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.

4 participants