Re: [BUGS] BUG #13793: Please implement IP_FREEBIND option

From: Christoph Berg <myon(at)debian(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: tomek(at)pipebreaker(dot)pl, Sebastian Elisa Pfeifer <s(dot)pfeifer(at)ixolit(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: [BUGS] BUG #13793: Please implement IP_FREEBIND option
Date: 2018-09-10 14:03:01
Message-ID: 20180910140301.GF20917@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: Tom Lane 2018-09-10 <9118(dot)1536587267(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2018-09-10 14:12:15 BUG #15377: SLES 11
Previous Message Tom Lane 2018-09-10 13:47:47 Re: [BUGS] BUG #13793: Please implement IP_FREEBIND option