postgresql/src
Tom Lane c781a066ea In libpq, don't look up all the hostnames at once.
Historically, we looked up the target hostname in connectDBStart, so that
PQconnectPoll did not need to do DNS name resolution.  The patches that
added multiple-target-host support to libpq preserved this division of
labor; but it's really nonsensical now, because it means that if any one
of the target hosts fails to resolve in DNS, the connection fails.  That
negates the no-single-point-of-failure goal of the feature.  Additionally,
DNS lookups aren't exactly cheap, but the code did them all even if the
first connection attempt succeeds.

Hence, rearrange so that PQconnectPoll does the lookups, and only looks
up a hostname when it's time to try that host.  This does mean that
PQconnectPoll could block on a DNS lookup --- but if you wanted to avoid
that, you should be using hostaddr, as the documentation has always
specified.  It seems fairly unlikely that any applications would really
care whether the lookup occurs inside PQconnectStart or PQconnectPoll.

In addition to calling out that fact explicitly, do some other minor
wordsmithing in the docs around the multiple-target-host feature.

Since this seems like a bug in the multiple-target-host feature,
backpatch to v10 where that was introduced.  In the back branches,
avoid moving any existing fields of struct pg_conn, just in case
any third-party code is looking into that struct.

Tom Lane, reviewed by Fabien Coelho

Discussion: https://postgr.es/m/4913.1533827102@sss.pgh.pa.us
2018-08-23 16:39:37 -04:00
..
backend Change PROCEDURE to FUNCTION in CREATE TRIGGER syntax 2018-08-22 14:45:07 +02:00
bin Copy-editing of pg_verify_checksums help and ref page 2018-08-23 20:33:39 +02:00
common Clean up assorted misuses of snprintf()'s result value. 2018-08-15 16:29:32 -04:00
fe_utils Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER commands. 2018-08-17 17:12:21 -04:00
include doc: Update uses of the word "procedure" 2018-08-22 14:45:07 +02:00
interfaces In libpq, don't look up all the hostnames at once. 2018-08-23 16:39:37 -04:00
makefiles Provide for contrib and pgxs modules to install include files. 2018-07-31 19:58:39 +01:00
pl PL/pgSQL: Extend test case 2018-08-23 17:22:33 +02:00
port Make snprintf.c follow the C99 standard for snprintf's result value. 2018-08-15 17:25:49 -04:00
template Force "restrict" not to be used when compiling with xlc. 2017-10-13 12:15:06 -07:00
test Change PROCEDURE to FUNCTION in CREATE TRIGGER syntax 2018-08-22 14:45:07 +02:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:56:22 -04:00
tools MSVC: Finish clean.bat tmp_check coverage. 2018-08-19 01:12:25 -07:00
tutorial Update copyright for 2018 2018-01-02 23:30:12 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Ensure we build generated headers at the start of some more cases. 2018-07-30 18:04:39 -04:00
Makefile.shlib Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-04-03 16:26:05 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00