Re: [PATCH] Allow Postgres to pick an unused port to listen

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yurii Rashkovskii <yrashk(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Allow Postgres to pick an unused port to listen
Date: 2023-03-29 11:55:43
Message-ID: 3803291.1680090943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Yurii Rashkovskii <yrashk(at)gmail(dot)com> writes:
> I would like to suggest a patch against master (although it may be worth
> backporting it) that makes it possible to listen on any unused port.

I think this is a bad idea, mainly because this:

> Instead, with this patch, one can specify `port` as `0` (the "wildcard"
> port) and retrieve the assigned port from postmaster.pid

is a horrid way to find out what was picked, and yet there could
be no other.

Our existing design for this sort of thing is to let the testing
framework choose the port, and I don't really see what's wrong
with that approach. Yes, I know it's theoretically subject to
race conditions, but that hasn't seemed to be a problem in
practice. It's especially not a problem given that modern
testing practice tends to not open any TCP port at all, just
a Unix socket in a test-private directory, so that port
conflicts are a non-issue.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-03-29 12:12:05 Re: BufmgrCommit no-op since 2008, remaining uses?
Previous Message Matthias van de Meent 2023-03-29 11:51:36 BufmgrCommit no-op since 2008, remaining uses?