diff options
author | Michael Paquier <michael@paquier.xyz> | 2019-04-06 15:23:37 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2019-04-06 15:23:37 +0900 |
commit | 249d64999615802752940e017ee5166e726bc7cd (patch) | |
tree | 0e66ac1723a854999e136e0c8cb3c3c4442b589d /src/include | |
parent | 959d00e9dbe4cfcf4a63bb655ac2c29a5e579246 (diff) |
Add support TCP user timeout in libpq and the backend server
Similarly to the set of parameters for keepalive, a connection parameter
for libpq is added as well as a backend GUC, called tcp_user_timeout.
Increasing the TCP user timeout is useful to allow a connection to
survive extended periods without end-to-end connection, and decreasing
it allows application to fail faster. By default, the parameter is 0,
which makes the connection use the system default, and follows a logic
close to the keepalive parameters in its handling. When connecting
through a Unix-socket domain, the parameters have no effect.
Author: Ryohei Nagaura
Reviewed-by: Fabien Coelho, Robert Haas, Kyotaro Horiguchi, Kirk
Jamison, Mikalai Keida, Takayuki Tsunakawa, Andrei Yahorau
Discussion: https://postgr.es/m/EDA4195584F5064680D8130B1CA91C45367328@G01JPEXMBYT04
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/libpq/libpq-be.h | 6 | ||||
-rw-r--r-- | src/include/utils/guc.h | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index b135ef9d9fd..00b1fbe4415 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -155,7 +155,7 @@ typedef struct Port HbaLine *hba; /* - * TCP keepalive settings. + * TCP keepalive and user timeout settings. * * default values are 0 if AF_UNIX or not yet known; current values are 0 * if AF_UNIX or using the default. Also, -1 in a default value means we @@ -164,9 +164,11 @@ typedef struct Port int default_keepalives_idle; int default_keepalives_interval; int default_keepalives_count; + int default_tcp_user_timeout; int keepalives_idle; int keepalives_interval; int keepalives_count; + int tcp_user_timeout; /* * GSSAPI structures. @@ -306,9 +308,11 @@ extern ProtocolVersion FrontendProtocol; extern int pq_getkeepalivesidle(Port *port); extern int pq_getkeepalivesinterval(Port *port); extern int pq_getkeepalivescount(Port *port); +extern int pq_gettcpusertimeout(Port *port); extern int pq_setkeepalivesidle(int idle, Port *port); extern int pq_setkeepalivesinterval(int interval, Port *port); extern int pq_setkeepalivescount(int count, Port *port); +extern int pq_settcpusertimeout(int timeout, Port *port); #endif /* LIBPQ_BE_H */ diff --git a/src/include/utils/guc.h b/src/include/utils/guc.h index 2f7cf919335..6c41edac008 100644 --- a/src/include/utils/guc.h +++ b/src/include/utils/guc.h @@ -271,6 +271,7 @@ extern PGDLLIMPORT char *application_name; extern int tcp_keepalives_idle; extern int tcp_keepalives_interval; extern int tcp_keepalives_count; +extern int tcp_user_timeout; #ifdef TRACE_SORT extern bool trace_sort; |