Skip to content

Enable TCP/IP keepalive for all ZK client connections in all components started with bin/pulsar - #15908

Merged
merlimat merged 1 commit into
apache:masterfrom
lhotari:lh-enable-zk-client-tcp-keepalive
Jun 4, 2022
Merged

Enable TCP/IP keepalive for all ZK client connections in all components started with bin/pulsar#15908
merlimat merged 1 commit into
apache:masterfrom
lhotari:lh-enable-zk-client-tcp-keepalive

Conversation

@lhotari

@lhotari lhotari commented Jun 2, 2022

Copy link
Copy Markdown
Member

Motivation

This is a follow-up on #12982 which enabled TCP/IP keepalive for ZK server side.
This PR enables TCP/IP keepalive for all ZK client connections in all components

  • Enable TCP keepAlive flag on the sockets used for client connections
    • see https://issues.apache.org/jira/browse/ZOOKEEPER-3712 for details
      • "Some broken network infrastructure may lose the FIN packet that is sent from closing client.
        These never closed client sockets cause OS resource leak. Enabling this option terminates
        these zombie sockets by idle check. ... Currently this option is only available
        when default NIOServerCnxnFactory is used."

Modifications

add -Dzookeeper.clientTcpKeepAlive=true to OPTS in bin/pulsar script so that the setting is passed to all components that are started using bin/pulsar script.

@lhotari lhotari added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages release/2.10.1 labels Jun 2, 2022
@lhotari lhotari added this to the 2.11.0 milestone Jun 2, 2022
@lhotari lhotari self-assigned this Jun 2, 2022
@github-actions

github-actions Bot commented Jun 2, 2022

Copy link
Copy Markdown

@lhotari:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@lhotari lhotari added the doc-not-needed Your PR changes do not impact docs label Jun 2, 2022
@github-actions

github-actions Bot commented Jun 2, 2022

Copy link
Copy Markdown

@lhotari:Thanks for providing doc info!

@Jason918 Jason918 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@michaeljmarshall michaeljmarshall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@merlimat
merlimat merged commit ede3d19 into apache:master Jun 4, 2022
lhotari added a commit that referenced this pull request Jun 6, 2022
nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request Jun 6, 2022
…ts (apache#15908)

(cherry picked from commit ede3d19)
(cherry picked from commit 77292ad)
@lhotari

lhotari commented Apr 28, 2026

Copy link
Copy Markdown
Member Author

It turns out that ZooKeeper TCP keepalive settings contain a major gap.

docs: https://zookeeper.apache.org/doc/current/zookeeperAdmin.html#:~:text=tcpKeepAlive%20%3A%20(Java%20system,NIOServerCnxnFactory%20is%20used.

tcpKeepAlive : (Java system property: zookeeper.tcpKeepAlive) New in 3.5.4: Setting this to true sets the TCP keepAlive flag on the sockets used by quorum members to perform elections. This will allow for connections between quorum members to remain up when there is network infrastructure that may otherwise break them. Some NATs and firewalls may terminate or lose state for long-running or idle connections. Enabling this option relies on OS level settings to work properly, check your operating system's options regarding TCP keepalive for more information. Defaults to false.

clientTcpKeepAlive : (Java system property: zookeeper.clientTcpKeepAlive) New in 3.6.1: Setting this to true sets the TCP keepAlive flag on the client sockets. Some broken network infrastructure may lose the FIN packet that is sent from closing client. These never closed client sockets cause OS resource leak. Enabling this option terminates these zombie sockets by idle check. Enabling this option relies on OS level settings to work properly, check your operating system's options regarding TCP keepalive for more information. Defaults to false. Please note the distinction between it and tcpKeepAlive. It is applied for the client sockets while tcpKeepAlive is for the sockets used by quorum members. Currently this option is only available when default NIOServerCnxnFactory is used.

The part "Please note the distinction between it and tcpKeepAlive. It is applied for the client sockets while tcpKeepAlive is for the sockets used by quorum members. Currently this option is only available when default NIOServerCnxnFactory is used."

  • the clientTcpKeepAlive is only applied on the server side for client sockets and it only handles NIOServerCnxnFactory
  • there is no setting to enable tcp keep-alive on the client side

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

Labels

cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.10.1 type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants