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

From: Christoph Berg <myon(at)debian(dot)org>
To: 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 13:33:09
Message-ID: 20180910133309.GE20917@msg.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Re: tomek(at)pipebreaker(dot)pl 2015-12-03 <20151203165520(dot)5892(dot)4072(at)wrigleys(dot)postgresql(dot)org>
> Bug reference: 13793
> Logged by: Tomasz Torcz
> Email address: tomek(at)pipebreaker(dot)pl
> PostgreSQL version: 9.4.5
> Operating system: Linux
> Description:
>
> IP_FREEBIND socket option allows application to bind on IP address, which i
> s not (yet) configured on any interface.
> I'd like to see Postgresql binding to all specified 'listen_addresses', even
> if some of then are not available at the moment pgsql starts.
> Optionally, postmaster could put in logs information about that action.
> Right know it is:
>
> LOG: could not bind IPv6 socket: Cannot assign requested address
> WARNING: could not create listen socket for "2001:DB8::1"
>
> It could be:
> LOG: could not bind IPv6 socket: Cannot assign requested address
> WARNING: binding anyway to "2001:DB8::1"

Re: To Sebastian Elisa Pfeifer 2018-09-07 <20180907143718(dot)GF29573(at)msg(dot)df7cb(dot)de>
> Re: Sebastian Elisa Pfeifer 2018-09-07 <ab23ab6a-f54a-4063-be3d-dbc93f5dedd2(at)ixolit(dot)com>
> > |2018-09-06 14:02:32 UTC LOG: could not bind IPv4 socket: Cannot assign
> > requested address 2018-09-06 14:02:32 UTC HINT: Is another postmaster
> > already running on port 5432? If not, wait a few seconds and retry.
> > 2018-09-06 14:02:32 UTC WARNING: could not create listen socket for
> > "123.123.123.123"|
> >
> > Possible fix: Adding the parameter After=network-online.target to it's
> > SystemD Unit file.
> >
> > Our setup includes the setting:
> > listen_addresses = 'localhost,123.123.123.123' (not the real IP)
>
> Hi,
>
> thanks for the report.
>
> I'll have to investigate if that's the correct fix in general. Afaict
> network-online.target does less than what the name says, i.e. some
> interfaces might still be configuring even at that point. Usual
> symptoms are IPv6 devices that are still in address discovery.

According to https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/ ,
network-online.target is meant to be used for networking clients that
need to actually access the network. For daemons that merely provide
networking services, the suggested solution is to enable IP_FREEBIND
on the socket:

http://man7.org/linux/man-pages/man7/ip.7.html

IP_FREEBIND (since Linux 2.4)
If enabled, this boolean option allows binding to an IP
address that is nonlocal or does not (yet) exist. This per‐
mits listening on a socket, without requiring the underlying
network interface or the specified dynamic IP address to be up
at the time that the application is trying to bind to it.
This option is the per-socket equivalent of the ip_nonlo‐
cal_bind /proc interface described below.

This had been requested in 2015 in bug #13793. I think it makes sense
to support this. Especially with IPv6, it is very common that
addresses are not yet assigned when services are starting. (I don't
know yet if other OSes support this option as well.)

Do we want that in PostgreSQL?

Christoph

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-09-10 13:47:47 Re: [BUGS] BUG #13793: Please implement IP_FREEBIND option
Previous Message kalyani kaniganti 2018-09-10 12:04:14 Re: BUG #15376: Postgres sql 9.4.19 pg_upgrade stops with error The source cluster was not shut down cleanly.