postgresql/src
Tom Lane fab84c7787 Improve PostgresNode.pm's logic for detecting already-in-use ports.
Buildfarm members bowerbird and jacana have shown intermittent "could not
bind IPv4 socket" failures in the BinInstallCheck stage since mid-December,
shortly after commits 1caef31d9e and 9821492ee4 changed the
logic for selecting which port to use in temporary installations.  One
plausible explanation is that we are randomly selecting ports that are
already in use for some non-Postgres purpose.  Although the code tried
to defend against already-in-use ports, it used pg_isready to probe
the port which is quite unhelpful: if some non-Postgres server responds
at the given address, pg_isready will generally say "no response",
leading to exactly the wrong conclusion about whether the port is free.

Instead, let's use a simple TCP connect() call to see if anything answers
without making assumptions about what it is.  Note that this means there's
no direct check for a conflicting Unix socket, but that should be okay
because there should be no other Unix sockets in use in the temporary
socket directory created for a test run.

This is only a partial solution for the TCP case, since if the port number
is in use for an outgoing connection rather than a listening socket, we'll
fail to detect that.  We could try to bind() to the proposed port as a
means of detecting that case, but that would introduce its own failure
modes, since the system might consider the address to remain reserved for
some period of time after we drop the bound socket.  Close study of the
errors returned by bowerbird and jacana suggests that what we're seeing
there may be conflicts with listening not outgoing sockets, so let's try
this and see if it improves matters.  It's certainly better than what's
there now, in any case.

Michael Paquier, adjusted by me to work on non-Windows as well as Windows
2016-04-24 15:31:45 -04:00
..
backend Fix documentation & config inconsistencies around 428b1d6b2. 2016-04-24 12:26:55 -07:00
bin Add pg_dump support for the new PARALLEL option for aggregates. 2016-04-20 23:06:06 -04:00
common Remove redundant message in AddUserToTokenDacl(). 2016-04-06 23:40:51 -04:00
fe_utils Support \crosstabview in psql 2016-04-08 20:23:18 -03:00
include Improve TranslateSocketError() to handle more Windows error codes. 2016-04-21 16:58:47 -04:00
interfaces Rename strtoi() to strtoint(). 2016-04-23 16:53:15 -04:00
makefiles Fix typos in comments and doc 2016-01-28 16:47:36 +09:00
pl Fix freshly-introduced PL/Python portability bug. 2016-04-11 18:17:20 -04:00
port Add putenv support for msvcrt from Visual Studio 2013 2016-04-22 05:18:59 -04:00
template Remove some remains from Alpha support removal 2015-10-29 16:40:14 -04:00
test Improve PostgresNode.pm's logic for detecting already-in-use ports. 2016-04-24 15:31:45 -04:00
timezone Suppress compiler warning. 2016-04-02 13:49:17 -04:00
tools Update helptext for vcregress.pl 2016-04-15 10:04:10 +02:00
tutorial Update copyright for 2016 2016-01-02 13:33:40 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS
Makefile Create src/fe_utils/, and move stuff into there from pg_dump's dumputils. 2016-03-24 15:55:57 -04:00
Makefile.global.in Create src/fe_utils/, and move stuff into there from pg_dump's dumputils. 2016-03-24 15:55:57 -04:00
Makefile.shlib AIX: Link TRANSFORM modules with their dependencies. 2015-07-15 21:00:26 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00