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

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
Thread:
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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Golub 2006-04-05 14:31:04 BUG #2377: pg_constraint didnt't updated when table columns deleted
Previous Message Brock Peabody 2006-04-05 14:12:26 Re: BUG #2371: database crashes with semctl failed error