Default: 0 (disabled)
+==== query_wait_timeout ====
+
+Maximum time queries are allowed to spend waiting for execution. If the query
+is not assigned to a server during that time, the client is disconnected. This
+is used to prevent unresponsive servers from grabbing up connections. [seconds]
+
+Default: 0 (disabled)
+
==== client_idle_timeout ====
Client connections idling longer than this many seconds are closed. This should
;; _not_ as statement_timeout. (default: 0)
;query_timeout = 0
+;; Dangerous. Client connection is closed if the query is not assigned
+;; to a server in this time. Should be used to limit the number of queued
+;; queries in case of a database or network failure. (default: 0)
+;query_wait_timeout = 0
+
;; Dangerous. Client connection is closed if no activity in this time.
;; Should be used to survive network problems. (default: 0)
;client_idle_timeout = 0
extern usec_t cf_server_connect_timeout;
extern usec_t cf_server_login_retry;
extern usec_t cf_query_timeout;
+extern usec_t cf_query_wait_timeout;
extern usec_t cf_client_idle_timeout;
extern usec_t cf_client_login_timeout;
extern int cf_server_round_robin;
}
}
- /* force client_query_timeout */
- if (cf_query_timeout > 0) {
+ /* force timeouts for waiting queries */
+ if (cf_query_timeout > 0 || cf_query_wait_timeout > 0) {
statlist_for_each_safe(item, &pool->waiting_client_list, tmp) {
client = container_of(item, PgSocket, head);
Assert(client->state == CL_WAITING);
//log_warning("query_start==0");
} else
age = now - client->query_start;
- if (age > cf_query_timeout)
+
+ if (cf_query_timeout > 0 && age > cf_query_timeout)
disconnect_client(client, true, "query_timeout");
+ else if (cf_query_wait_timeout > 0 && age > cf_query_wait_timeout)
+ disconnect_client(client, true, "query_wait_timeout");
}
}
usec_t cf_server_connect_timeout = 15*USEC;
usec_t cf_server_login_retry = 15*USEC;
usec_t cf_query_timeout = 0*USEC;
+usec_t cf_query_wait_timeout = 0*USEC;
usec_t cf_client_idle_timeout = 0*USEC;
usec_t cf_client_login_timeout = 60*USEC;
usec_t cf_suspend_timeout = 10*USEC;
{"server_check_query", true, CF_STR, &cf_server_check_query},
{"server_check_delay", true, CF_TIME, &cf_server_check_delay},
{"query_timeout", true, CF_TIME, &cf_query_timeout},
+{"query_wait_timeout", true, CF_TIME, &cf_query_wait_timeout},
{"client_idle_timeout", true, CF_TIME, &cf_client_idle_timeout},
{"client_login_timeout",true, CF_TIME, &cf_client_login_timeout},
{"server_lifetime", true, CF_TIME, &cf_server_lifetime},