From: reda-alaoui (@reda-alaoui) <noreply+reda-alaoui@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #3964: feat: add tcpKeepAliveCount, tcpKeepAliveIdle and tcpKeepAliveInterval connection properties
Date: Sun, 26 Jul 2026 08:44:28 +0000
Message-ID: <gh-pgjdbc-pgjdbc-3964-c5082767271@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-3964@github.com>
References: <gh-pgjdbc-pgjdbc-3964@github.com>
> One naming suggestion before this ships, since these constants and property names are new and not yet released, so renaming them now costs nothing in compatibility.
>
> Right now the three new options share only the `tcpKeep` stem with the existing `tcpKeepAlive` toggle. Read in isolation, `tcpKeepCount` is a little ambiguous ("keep count of what?"). I'd suggest grouping all three under the full `tcpKeepAlive` family:
>
> Concept This PR Suggested
> probe count `tcpKeepCount` / `TCP_KEEP_COUNT` `tcpKeepAliveCount` / `TCP_KEEP_ALIVE_COUNT`
> idle before first probe `tcpKeepIdle` / `TCP_KEEP_IDLE` `tcpKeepAliveIdle` / `TCP_KEEP_ALIVE_IDLE`
> interval between probes `tcpKeepInterval` / `TCP_KEEP_INTERVAL` `tcpKeepAliveInterval` / `TCP_KEEP_ALIVE_INTERVAL`
> The `BaseDataSource` accessors would follow: `getTcpKeepAliveCount()` / `setTcpKeepAliveCount(Integer)`, and so on.
>
> Reasons:
>
> * It matches how pgjdbc already groups related options under a feature prefix — see the `ssl` family (`ssl`, `sslmode`, `sslcert`, `sslkey`, `sslrootcert`, `sslpassword`). A `tcpKeepAlive` toggle plus `tcpKeepAlive*` sub-options is the same shape, so this follows the existing convention rather than departing from it.
> * The prefix also signals the dependency: these three only take effect when `tcpKeepAlive=true` (`SO_KEEPALIVE` must be on). That answers your earlier question about whether they apply without keep-alive being enabled — they don't, and the name now makes that clear. It's worth a note in the docs too, the way libpq documents `keepalives_idle` as applying only when `keepalives` is on.
>
> The tradeoff is that we move further from the JDK constant names (`TCP_KEEPCOUNT` / `TCP_KEEPIDLE` / `TCP_KEEPINTERVAL`) and libpq's `keepalives_*`. That's fine for the user-facing names — pgjdbc already uses its own camelCase and doesn't mirror either. Those JDK names are still the accurate label for the internal `ExtendedSocketOptionAccessor` methods, which wrap the socket options directly, so I'd leave that internal layer as-is and rename only the public surface (`PGProperty` + `BaseDataSource`).
Done :+1: