postgresql/src
Tom Lane 5987feb70b Make PQcancel use the PGconn's tcp_user_timeout and keepalives settings.
If connectivity to the server has been lost or become flaky, the
user might well try to send a query cancel.  It's highly annoying
if PQcancel hangs up in such a case, but that's exactly what's likely
to happen.  To ameliorate this problem, apply the PGconn's
tcp_user_timeout and keepalives settings to the TCP connection used
to send the cancel.  This should be safe on Unix machines, since POSIX
specifies that setsockopt() is async-signal-safe.  We are guessing
that WSAIoctl(SIO_KEEPALIVE_VALS) is similarly safe on Windows.
(Note that at least in psql and our other frontend programs, there's
no safety issue involved anyway, since we run PQcancel in its own
thread rather than in a signal handler.)

Most of the value here comes from the expectation that tcp_user_timeout
will be applied as a connection timeout.  That appears to happen on
Linux, even though its tcp(7) man page claims differently.  The
keepalive options probably won't help much, but as long as we can
apply them for not much code, we might as well.

Jelte Fennema, reviewed by Fujii Masao and myself

Discussion: https://postgr.es/m/AM5PR83MB017870DE81FC84D5E21E9D1EF7AA9@AM5PR83MB0178.EURPRD83.prod.outlook.com
2022-01-18 14:13:13 -05:00
..
backend Modify pg_basebackup to use a new COPY subprotocol for base backups. 2022-01-18 13:47:49 -05:00
bin Modify pg_basebackup to use a new COPY subprotocol for base backups. 2022-01-18 13:47:49 -05:00
common Improve code clarity in epilogue of UTF-8 verification fast path 2022-01-17 22:53:50 -05:00
fe_utils Avoid calling gettext() in signal handlers. 2022-01-17 13:30:04 -05:00
include Modify pg_basebackup to use a new COPY subprotocol for base backups. 2022-01-18 13:47:49 -05:00
interfaces Make PQcancel use the PGconn's tcp_user_timeout and keepalives settings. 2022-01-18 14:13:13 -05:00
makefiles
pl Update copyright for 2022 2022-01-07 19:04:57 -05:00
port Clean up messy API for src/port/thread.c. 2022-01-11 13:46:20 -05:00
template
test Try to stabilize the reloptions test. 2022-01-19 07:25:21 +13:00
timezone Update copyright for 2022 2022-01-07 19:04:57 -05:00
tools Move 027_stream_regress.pl's output to tmp_check. 2022-01-18 08:07:29 +13:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Add support for LZ4 compression in pg_receivewal 2021-11-05 11:33:25 +09:00
Makefile.shlib
nls-global.mk