Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uZmfH-00828w-3F for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jul 2025 08:29:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uZmfF-009zfE-5N for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Jul 2025 08:29:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uZmfE-009zf5-TP for pgsql-bugs@lists.postgresql.org; Thu, 10 Jul 2025 08:29:57 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uZmfD-006oEN-1C for pgsql-bugs@lists.postgresql.org; Thu, 10 Jul 2025 08:29:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1752136193; bh=49LKk6iX9r7awNRuunskHOVMnB+y5QJxqdSzCjZDDrI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:Message-ID:From; b=ZrZuIUxT69Zf/1RryZg4ZtDbLj2YsT1kJPKE//mwK+qoG6bDDD5SmJ2pbuzz1DxSr HbFhEzIaYNLNKrT9e0Zibc/8OxuUlBISwWOhUhsioGW6O6Om02zKxwebcvO7LUjUn9 BEWktYTMsgkd/000qXsfIUuy8ll7f1Cd5mcSw0REy4JfPo6iqPSaN5DkW99mV6z3Zk be7PlezaNIf9OQEFW3hLFWmce0XSSGL0zf0KeGfaEmj4KJfzlfjNhkEU/y6wayJ4QB fj+IBz9tIVNPUj9JHFvpQcPomDLjwAWQ+qxnflP2limfMRwS6q0UNU6yq3MH2yASjT 2FESicKV2I2cg== Received: from mail.postgrespro.ru (webmail-master-mstn.l.postgrespro.ru [192.168.2.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.mitrokhin@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 919F8608E4; Thu, 10 Jul 2025 11:29:53 +0300 (MSK) MIME-Version: 1.0 Date: Thu, 10 Jul 2025 15:29:53 +0700 From: a.mitrokhin@postgrespro.ru To: Kirill Reshke Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Starting a PostgreSQL server on a dynamic port (parameter port=0) In-Reply-To: References: <824bbf6be5fa0edf6a7d4c8371ce67ce@postgrespro.ru> Message-ID: X-Sender: a.mitrokhin@postgrespro.ru Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/07/10 08:01:00 #27632768 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Kirill Reshke писал(а) 2025-07-10 14:46: > On Thu, 10 Jul 2025 at 12:15, wrote: >> >> Hello. >> >> >> Postgres does not allow starting the server with port=0, which >> prevents >> it from obtaining an arbitrary free port from the kernel. >> >> >> ~$ LANG=C pg_ctl -D data -o "-c port=0" start >> 2025-07-10 05:27:02.785 GMT [702503] FATAL: 0 is outside the valid >> range for parameter "port" (1 .. 65535) >> >> >> This makes it unreliable to start the server in my tests without the >> risk of port conflicts with already running programs, unless resorting >> to an unreliable and race-condition-prone procedure of reserving ports >> in advance. >> >> >> Could you please fix this? > > > Regression tests somehow solve this problem without any patch, so why > this should be fixed? This has nothing to do with Postgres regression tests. The issue is the practical benefit of using a dynamic port, which we're depriving ourselves of. If you're not interested in this behavior, you'll never use it. But there are cases where it can be very convenient. Why artificially restrict functionality that is simple, doesn't conflict with anything, and has no negative side effects?