pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix libpq's implementation of per-host connection timeouts. 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix libpq's implementation of per-host connection timeouts. @ 2018-08-13 17:08 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-08-13 17:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix libpq's implementation of per-host connection timeouts. @ 2018-08-13 17:08 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-08-13 17:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/998c7366414ad6f93c2643339499ce9e6ab007eb Modified Files -------------- doc/src/sgml/libpq.sgml | 9 +++++---- src/interfaces/libpq/fe-connect.c | 35 ++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 17 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix libpq's implementation of per-host connection timeouts. @ 2018-08-13 17:08 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2018-08-13 17:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e0db288abfa8cfd2e471017441e401e8f92aeda7 Modified Files -------------- doc/src/sgml/libpq.sgml | 11 ++++++----- src/interfaces/libpq/fe-connect.c | 35 ++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 18 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-08-13 17:08 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2018-08-13 17:08 pgsql: Fix libpq's implementation of per-host connection timeouts. Tom Lane <tgl@sss.pgh.pa.us> 2018-08-13 17:08 pgsql: Fix libpq's implementation of per-host connection timeouts. Tom Lane <tgl@sss.pgh.pa.us> 2018-08-13 17:08 pgsql: Fix libpq's implementation of per-host connection timeouts. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox