pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Markus Pilman <markus@pilman.ch>
Cc: pgsql-general@postgresql.org
Subject: Re: Binding Postgres to port 0 for testing
Date: Mon, 27 Mar 2023 14:10:30 +0900
Message-ID: <ZCElRnKJ6v67SCOd@paquier.xyz> (raw)
In-Reply-To: <CALavoow6oTvy5fFZ9c5Pcyc6Sga51XdFDEt87pRQLs5RmaFjYw@mail.gmail.com>
References: <CALavoowMtHgaX_pVhtkVuynYcjM8k7cF4DxxLzcp7ih7JEoRAw@mail.gmail.com>
	<ZCDxDqcuaK0FODCs@paquier.xyz>
	<CALavoow6oTvy5fFZ9c5Pcyc6Sga51XdFDEt87pRQLs5RmaFjYw@mail.gmail.com>

On Sun, Mar 26, 2023 at 10:49:33PM -0600, Markus Pilman wrote:
> I somehow didn't consider looking at the postgres tests, though it makes
> sense that they need to solve this problem. If I read the perl code
> correctly though it seems that this could, in theory, cause a race? The
> script checks first whether the port has been assigned to a test, then
> binds a socket to check whether it is used by someone else, closes this
> test socker, and then starts a server process. I guess it's unlikely
> enough, but isn't there a risk that some other process (that isn't
> controlled by this perl script) binds to the found port right after this
> test bind but right before postgres calls bind? I guess it should be rare
> enough so that it wouldn't cause flaky tests.

In theory, yes, I recall that's possible in the scripts.  But only on
Windows where we cannot use socket directories and rely on SSPI
authentication while binding all the nodes to listen to 127.0.0.1.  On
all the other platforms, each test creates its own directory that will
be used as path for unix_socket_directories.  umask is 0700 and owned
by the OS user running the perl tests, so it is isolated as much as it
can be.  Using the same port should be actually fine as far as I
recall, as long as the unix socket paths are different.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (8+ messages)

Message-ID: <ZCElRnKJ6v67SCOd@paquier.xyz>
Permalink:  ../ZCElRnKJ6v67SCOd@paquier.xyz/
Also on:    postgresql.org/message-id/ZCElRnKJ6v67SCOd@paquier.xyz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: michael@paquier.xyz, markus@pilman.ch
  Subject: Re: Binding Postgres to port 0 for testing
  In-Reply-To: <ZCElRnKJ6v67SCOd@paquier.xyz>
  References: <CALavoowMtHgaX_pVhtkVuynYcjM8k7cF4DxxLzcp7ih7JEoRAw@mail.gmail.com> <ZCDxDqcuaK0FODCs@paquier.xyz> <CALavoow6oTvy5fFZ9c5Pcyc6Sga51XdFDEt87pRQLs5RmaFjYw@mail.gmail.com> <ZCElRnKJ6v67SCOd@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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