On Fri, 2013-05-10 at 18:17 -0400, Tom Lane wrote:
> It's probably not really necessary for the test script to try to
> duplicate the dynamic port-number testing done in pg_regress.c
> (especially since that isn't terribly bulletproof anyway). However,
> I think it should at least replicate this bit of logic:
>
> /*
> * To reduce chances of interference with parallel
> installations, use
> * a port number starting in the private range (49152-65535)
> * calculated from the version number.
> */
> port = 0xC000 | (PG_VERSION_NUM & 0x3FFF);
>
> since that should only take a couple of lines of shell scripting,
> and is enough to avoid collisions in ordinary cases.
That would be a good idea, but it seems independent of the code I
removed.
The only reason that the pg_upgrade test suite stayed out of the way of
the default port number is that it used a different hard-coded port
number, which also happened to be the production pg_upgrade port number.
That code was put in there before pg_upgrade itself switched to using
50432 by default.
The effect of having left that code in there was that multiple
concurrent pg_upgrade tests in different code trees with different
default ports would interfere with each other. That problem still
exists on platforms without Unix-domain sockets, however.
I think the complete solution here is something like
random_port=$(secret algorithm)
PGPORT=$random_port
PGOLDPORT=$random_port
PGNEWPORT=$random_port
export PGPORT PGOLDPORT PGNEWPORT