pgsql: Fix libpq's implementation of per-host connection timeouts.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix libpq's implementation of per-host connection timeouts.
Дата
Msg-id E1fpGK6-00079R-QM@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix libpq's implementation of per-host connection timeouts.

Commit 5f374fe7a attempted to turn the connect_timeout from an overall
maximum time limit into a per-host limit, but it didn't do a great job of
that.  The timer would only get restarted if we actually detected timeout
within connectDBComplete(), not if we changed our attention to a new host
for some other reason.  In that case the old timeout continued to run,
possibly causing a premature timeout failure for the new host.

Fix that, and also tweak the logic so that if we do get a timeout,
we advance to the next available IP address, not to the next host name.
There doesn't seem to be a good reason to assume that all the IP
addresses supplied for a given host name will necessarily fail the
same way as the current one.  Moreover, this conforms better to the
admittedly-vague documentation statement that the timeout is "per
connection attempt".  I changed that to "per host name or IP address"
to be clearer.  (Note that reconnections to the same server, such as for
switching protocol version or SSL status, don't get their own separate
timeout; that was true before and remains so.)

Also clarify documentation about the interpretation of connect_timeout
values less than 2.

This seems like a bug, so back-patch to v10 where this logic came in.

Tom Lane, reviewed by Fabien Coelho

Discussion: https://postgr.es/m/5735.1533828184@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1e6e98f7638904b2aa4df0bd87064239ce9d8fcf

Modified Files
--------------
doc/src/sgml/libpq.sgml           |  9 +++++----
src/interfaces/libpq/fe-connect.c | 35 ++++++++++++++++++++++-------------
2 files changed, 27 insertions(+), 17 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: pgsql: Make autovacuum more aggressive to remove orphaned temp tables
Следующее
От: Peter Eisentraut
Дата:
Сообщение: pgsql: Remove obsolete comment