mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
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
This commit is contained in:
@@ -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 */
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user