Re: PGSTAT: bind(2): Can't assign requested address

Lists: pgsql-bugs
From: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: PGSTAT: bind(2): Can't assign requested address
Date: 2002-05-26 17:28:11
Message-ID: Pine.BSF.4.44.0205261901190.20197-100000@e0-0.zab2.int.zabbadoz.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

PRIO: low

Hi,

in src/backend/postmaster/pgstat.c there is a hard coded bind to
127.0.0.1 that fails if 127.0.0.1 is not configured on loopback
interface (e.g. administrator explicitly removed this IP).
This should _not_ be the case in normal setups.

--- gmake check ---
...
============== creating temporary installation ==============
============== initializing database system ==============
============== starting postmaster ==============

pg_regress: postmaster did not start
Examine ./log/postmaster.log for the reason.

kill: 97857: No such process
rm regress.o
gmake[2]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test/regress'
gmake[1]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test'
% cat src/test/regress/log/postmaster.log
PGSTAT: bind(2): Can't assign requested address
--- snipp ---

With postgresql-7.2.1 (and perhaps also earlier versions ?) this
prevents postmaster from starting if one does not configure
'stats_start_collector = false'.
This works as a workaround.
One may also patch the sources and recompile of course.

I have seen that there were changes in CVS already but the 127.0.0.1 is
still hard coded in there.

I discovered that after playing with some routing daemons on my test
machine and therefor had removed 127.0.0.1. OS was FreeBSD 4.5-STABLE
but that shouldn't matter.

--
Greetings

Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT
56 69 73 69 74 http://www.zabbadoz.net/


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2002-06-07 22:47:52
Message-ID: 200206072247.g57Mlq702565@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


Well, you are the first to report that 127.0.0.1 doesn't work for stats.
Unless someone else has a problem, I think we will leave it unchanged.

---------------------------------------------------------------------------

Bjoern A. Zeeb wrote:
> PRIO: low
>
> Hi,
>
> in src/backend/postmaster/pgstat.c there is a hard coded bind to
> 127.0.0.1 that fails if 127.0.0.1 is not configured on loopback
> interface (e.g. administrator explicitly removed this IP).
> This should _not_ be the case in normal setups.
>
> --- gmake check ---
> ...
> ============== creating temporary installation ==============
> ============== initializing database system ==============
> ============== starting postmaster ==============
>
> pg_regress: postmaster did not start
> Examine ./log/postmaster.log for the reason.
>
> kill: 97857: No such process
> rm regress.o
> gmake[2]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test/regress'
> gmake[1]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test'
> % cat src/test/regress/log/postmaster.log
> PGSTAT: bind(2): Can't assign requested address
> --- snipp ---
>
> With postgresql-7.2.1 (and perhaps also earlier versions ?) this
> prevents postmaster from starting if one does not configure
> 'stats_start_collector = false'.
> This works as a workaround.
> One may also patch the sources and recompile of course.
>
> I have seen that there were changes in CVS already but the 127.0.0.1 is
> still hard coded in there.
>
> I discovered that after playing with some routing daemons on my test
> machine and therefor had removed 127.0.0.1. OS was FreeBSD 4.5-STABLE
> but that shouldn't matter.
>
> --
> Greetings
>
> Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT
> 56 69 73 69 74 http://www.zabbadoz.net/
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026


From: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-05 14:16:24
Message-ID: 20060405135540.T76259@maildrop.int.zabbadoz.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, 7 Jun 2002, Bruce Momjian wrote:

Hi,

it's been some months so I left the fullquote attached.

> Well, you are the first to report that 127.0.0.1 doesn't work for stats.
> Unless someone else has a problem, I think we will leave it unchanged.

The last years this problem was disucced several times (mostly on
FreeBSD lists) for the reason of FreeBSD jails. I thought that we
had another mail in 2002 about that but couldn't find it anymore.

Anyway binding to 127.0.0.1 in a jail binds to the (usually public) IP
address of that jail which means the stats socket is basically open to
world (from the socket point of view).

Another problem (which is not a postgresql problem per se) is that if
the system is built without inet6 support or does not support inet6
(as in jails) but there is a ::1 localhost in /etc/hosts the error
messages gives a warning like:
could not create socket for statistics collector:
Protocol not supported
which sound annoying in first places until you find out that it worked
anyway and remember what cuases the warning.

Is there any reason why you explicitly disallow a posix local socket
at that point in backend/postmaster/pgstat.c:pgstat_init:

...
for (addr = addrs; addr; addr = addr->ai_next)
{
#ifdef HAVE_UNIX_SOCKETS
/* Ignore AF_UNIX sockets, if any are returned. */
if (addr->ai_family == AF_UNIX)
continue;
#endif
...

Couldn't you use/allow (if possible or configured) a posix local socket
or even use pipes for that?

Greetings
Bjoern A. Zeeb

> ---------------------------------------------------------------------------
>
> Bjoern A. Zeeb wrote:
>> PRIO: low
>>
>> Hi,
>>
>> in src/backend/postmaster/pgstat.c there is a hard coded bind to
>> 127.0.0.1 that fails if 127.0.0.1 is not configured on loopback
>> interface (e.g. administrator explicitly removed this IP).
>> This should _not_ be the case in normal setups.
>>
>> --- gmake check ---
>> ...
>> ============== creating temporary installation ==============
>> ============== initializing database system ==============
>> ============== starting postmaster ==============
>>
>> pg_regress: postmaster did not start
>> Examine ./log/postmaster.log for the reason.
>>
>> kill: 97857: No such process
>> rm regress.o
>> gmake[2]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test/regress'
>> gmake[1]: Leaving directory `/u1/local/src/postgresql/postgresql-7.2.1/src/test'
>> % cat src/test/regress/log/postmaster.log
>> PGSTAT: bind(2): Can't assign requested address
>> --- snipp ---
>>
>> With postgresql-7.2.1 (and perhaps also earlier versions ?) this
>> prevents postmaster from starting if one does not configure
>> 'stats_start_collector = false'.
>> This works as a workaround.
>> One may also patch the sources and recompile of course.
>>
>> I have seen that there were changes in CVS already but the 127.0.0.1 is
>> still hard coded in there.
>>
>> I discovered that after playing with some routing daemons on my test
>> machine and therefor had removed 127.0.0.1. OS was FreeBSD 4.5-STABLE
>> but that shouldn't matter.

--
Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-05 14:59:53
Message-ID: 398.1144249193@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Bjoern A. Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net> writes:
> Is there any reason why you explicitly disallow a posix local socket
> at that point in backend/postmaster/pgstat.c:pgstat_init:

Because we want UDP, not a Unix socket.

regards, tom lane


From: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-05 15:28:10
Message-ID: 20060405150230.K76259@maildrop.int.zabbadoz.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, 5 Apr 2006, Tom Lane wrote:

Hi,

> "Bjoern A. Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net> writes:
>> Is there any reason why you explicitly disallow a posix local socket
>> at that point in backend/postmaster/pgstat.c:pgstat_init:
>
> Because we want UDP, not a Unix socket.

what you are giving there as hints is

hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;

A datagram socket (SOCK_DGRAM) is called "UDP Socket" when it
assumes IP (AF_INET) or IPv6 (AF_INET6) as it's underlying
protocol.

But you can always use SOCK_DGRAM over AF_LOCAL.
Stevens gives some good reasons to do so, especially if both
peers are on the same host.

If there is no need for using the INET(6) protcotol familiy
(an I cannot see it as long as we stay on the same host)
you may really want to consider using posix local sockets.

Greetings
Bjoern

--
Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-05 15:35:39
Message-ID: 7221.1144251339@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Bjoern A. Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net> writes:
> A datagram socket (SOCK_DGRAM) is called "UDP Socket" when it
> assumes IP (AF_INET) or IPv6 (AF_INET6) as it's underlying
> protocol.
> But you can always use SOCK_DGRAM over AF_LOCAL.

I'm unconvinced that that has the same semantics on all platforms.
Unix pipes traditionally have different behavior with respect to
blocking, partial message send, etc.

regards, tom lane


From: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-05 16:49:59
Message-ID: 20060405162701.W76259@maildrop.int.zabbadoz.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Wed, 5 Apr 2006, Tom Lane wrote:

> "Bjoern A. Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net> writes:
>> A datagram socket (SOCK_DGRAM) is called "UDP Socket" when it
>> assumes IP (AF_INET) or IPv6 (AF_INET6) as it's underlying
>> protocol.
>> But you can always use SOCK_DGRAM over AF_LOCAL.
>
> I'm unconvinced that that has the same semantics on all platforms.
> Unix pipes traditionally have different behavior with respect to
> blocking, partial message send, etc.

Are you worried about posix local sockets in general? Or are you
worried about doing sock_dgram over posix local sockets?

just some more thoughts...

- libpq uses posix local sockets (even streaming) as default if
available and no hostname is given. I'd be more worried about
my data...

- posix local sockets have been around for ages and I'd rather
rely on posix local sockets than any IPv6 protocol implementation.

- it's the same API on top of them

- it's posix these days

- it could be configurable/optional

--
Bjoern A. Zeeb bzeeb at Zabbadoz dot NeT


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: "Bjoern A(dot) Zeeb" <bzeeb-lists(at)lists(dot)zabbadoz(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: PGSTAT: bind(2): Can't assign requested address
Date: 2006-04-20 10:50:27
Message-ID: 200604201050.k3KAoRd05436@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Bjoern A. Zeeb wrote:
> On Fri, 7 Jun 2002, Bruce Momjian wrote:
>
> Hi,
>
> it's been some months so I left the fullquote attached.
>
> > Well, you are the first to report that 127.0.0.1 doesn't work for stats.
> > Unless someone else has a problem, I think we will leave it unchanged.
>
>
> The last years this problem was disucced several times (mostly on
> FreeBSD lists) for the reason of FreeBSD jails. I thought that we
> had another mail in 2002 about that but couldn't find it anymore.
>
> Anyway binding to 127.0.0.1 in a jail binds to the (usually public) IP
> address of that jail which means the stats socket is basically open to
> world (from the socket point of view).

Yes, but we need an interface that will drop packets on heavy load, and
a local IP is the only way we know to do that.

> Another problem (which is not a postgresql problem per se) is that if
> the system is built without inet6 support or does not support inet6
> (as in jails) but there is a ::1 localhost in /etc/hosts the error
> messages gives a warning like:
> could not create socket for statistics collector:
> Protocol not supported
> which sound annoying in first places until you find out that it worked
> anyway and remember what cuases the warning.

Yes, that is confusing. The following patch adds a message after the
error:

trying another address for the statistics collector

which should help reduce confusion. It will appear in 8.2.

> Is there any reason why you explicitly disallow a posix local socket
> at that point in backend/postmaster/pgstat.c:pgstat_init:
>
> ...
> for (addr = addrs; addr; addr = addr->ai_next)
> {
> #ifdef HAVE_UNIX_SOCKETS
> /* Ignore AF_UNIX sockets, if any are returned. */
> if (addr->ai_family == AF_UNIX)
> continue;
> #endif
> ...
>
>
> Couldn't you use/allow (if possible or configured) a posix local socket
> or even use pipes for that?

Yes, because it can't drop packets, I think.

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
unknown_filename text/plain 870 bytes