From 249d64999615802752940e017ee5166e726bc7cd Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Sat, 6 Apr 2019 15:23:37 +0900 Subject: 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 --- src/include/libpq/libpq-be.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/include/libpq') 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 */ -- cgit v1.2.3