Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMmX-0004pq-Ay for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Sep 2018 14:03:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fzMmV-0000mr-5w for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Sep 2018 14:03:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMmU-0000mj-Ss for pgsql-bugs@lists.postgresql.org; Mon, 10 Sep 2018 14:03:11 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fzMmN-0006U2-8N for pgsql-bugs@postgresql.org; Mon, 10 Sep 2018 14:03:09 +0000 Received: from msg.df7cb.de (unknown [IPv6:2003:5b:203b:100:7627:eaff:fe52:8e03]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 4288rj33mDz3Dyx; Mon, 10 Sep 2018 16:03:01 +0200 (CEST) Date: Mon, 10 Sep 2018 16:03:01 +0200 From: Christoph Berg To: Tom Lane Cc: tomek@pipebreaker.pl, Sebastian Elisa Pfeifer , pgsql-bugs@postgresql.org Subject: Re: [BUGS] BUG #13793: Please implement IP_FREEBIND option Message-ID: <20180910140301.GF20917@msg.df7cb.de> Mail-Followup-To: Christoph Berg , Tom Lane , tomek@pipebreaker.pl, Sebastian Elisa Pfeifer , pgsql-bugs@postgresql.org References: <20180910133309.GE20917@msg.df7cb.de> <9118.1536587267@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9118.1536587267@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Re: Tom Lane 2018-09-10 <9118.1536587267@sss.pgh.pa.us> > > Do we want that in PostgreSQL? > > IIRC, the main concern expressed previously is that this would completely > defeat error checking on the listen_addresses parameter. However, that > doesn't apply if said parameter is "*". Would there be any sense in > applying IP_FREEBIND only for "*"? "*" should work always, so IP_FREEBIND shouldn't make any difference. In the meantime I found https://bugzilla.redhat.com/show_bug.cgi?id=1357199 (from July 2016) where the problem had been discussed before. Re error checking, the state at the moment is actually worse than it would be with IP_FREEBIND. If multiple addresses are configured, and only one of them fails, there is no error, and startup proceeds: listen_addresses = 'localhost,1.2.3.4' LOG: listening on IPv6 address "::1", port 5432 LOG: listening on IPv4 address "127.0.0.1", port 5432 LOG: could not bind IPv4 address "1.2.3.4": Cannot assign requested address HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. WARNING: could not create listen socket for "1.2.3.4" So unless the user checks the log, everything seems fine, but actually the socket is unreachable. With IP_FREEBIND, we could still log a WARNING first, and then proceed with binding. With only one IP configured, there is an ERROR: LOG: could not bind IPv4 address "1.2.3.4": Cannot assign requested address HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. WARNING: could not create listen socket for "1.2.3.4" FATAL: could not create any TCP/IP sockets I think it is a bug that these cases behave differently. I'd opt to apply IP_FREEBIND (and hopefully the equivalent on other kernels), and log a WARNING. Binding to a IP that is not assigned is also an important use-case in HA setups that have a virtual (floating) IP. Christoph