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

From: Yurii Rashkovskii <yrashk(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: [PATCH] Allow Postgres to pick an unused port to listen
Date: 2023-03-29 05:18:55
Message-ID: CA+RLCQwJBGAnBo7OZ6QxqJjEn6w=Mju9GrHQmwFxX_io+4Cwhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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.

The main motivation is running colocated instances of Postgres (such as
test benches) without having to coordinate port allocation in an
unnecessarily complicated way.

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

I believe there is no significant performance or another impact as it is a
tiny bit of conditional functionality executed during startup.

The patch builds and `make check` succeeds. The patch does not add a test;
however, I am trying to figure out if this behaviour can be tested
automatically.

--
http://omnigres.org
Y.

Attachment Content-Type Size
V1-0001-Allow-listening-port-to-be-0.patch application/octet-stream 7.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2023-03-29 05:27:02 Re: Using Ephemeral Named Relation like a temporary table
Previous Message Yugo NAGATA 2023-03-29 04:53:52 Using Ephemeral Named Relation like a temporary table