Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support TCP keepalive and user timeout settings #570

Open
jaroslawr opened this issue Feb 11, 2022 · 1 comment
Open

Support TCP keepalive and user timeout settings #570

jaroslawr opened this issue Feb 11, 2022 · 1 comment

Comments

@jaroslawr
Copy link

Postgres C client libpq supports several options for setting up TCP keepalive:

keepalives_idle
keepalives_interval
keepalives_count
tcp_user_timeout

https://www.postgresql.org/docs/13/libpq-connect.html

Postgres traditional pgjdbc Java client cannot support equivalent options, because it uses traditional Java sockets which do not support the relevant OS socket options. Thus pgjdbc only has a binary TCP keepalive on/off switch, but TCP keepalive without tcp_user_timeout is not reliable, as explained by:

https://blog.cloudflare.com/when-tcp-sockets-refuse-to-die/
https://codearcana.com/posts/2015/08/28/tcp-keepalive-is-a-lie.html

Netty on the other hand has all the relevant support in EpollSocketChannelConfig methods:
setTcpKeepIdle
setTcpKeepIntvl
setTcpKeepCnt
setTcpUserTimeout

pgjdbc-ng could expose configuration options similar to those offered by libpq, that would in effect change the EpollSocketChannelConfig for PG connections (and then it needs to handle the socket timeout correctly, maybe it already does?).

@jaroslawr
Copy link
Author

(This functionality makes client-side load balancing between PG connections possible with reliable failover and no global query timeout)

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

No branches or pull requests

1 participant