Re: duplicate connection failure messages

Lists: pgsql-hackers
From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: duplicate connection failure messages
Date: 2010-10-13 19:21:02
Message-ID: 1286997662.4671.17.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

This surprised me:

psql -p 55555 -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 55555?
could not connect to server: Connection refused
Is the server running on host "localhost" and accepting
TCP/IP connections on port 55555?

It shows the same error message twice. I can reproduce this back to PG
8.2.

It appears to have something to do with localhost resolving to an IPv4
and an IPv6 address, since it doesn't happen with other host names that
only resolve to one address. However, fe-connect.c claims:

/*
* Try to initiate a connection to one of the addresses
* returned by pg_getaddrinfo_all(). conn->addr_cur is the
* next one to try. We fail when we run out of addresses
* (reporting the error returned for the *last* alternative,
* which may not be what users expect :-().
*/


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-10-14 05:30:36
Message-ID: AANLkTikrYV2BPV=2UY7OYkOoJsQjs3EQKYeH_tdU4rbU@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 13, 2010 at 21:21, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> This surprised me:
>
> psql -p 55555 -h localhost
> psql: could not connect to server: Connection refused
>        Is the server running on host "localhost" and accepting
>        TCP/IP connections on port 55555?
> could not connect to server: Connection refused
>        Is the server running on host "localhost" and accepting
>        TCP/IP connections on port 55555?
>
> It shows the same error message twice.  I can reproduce this back to PG
> 8.2.
>
> It appears to have something to do with localhost resolving to an IPv4
> and an IPv6 address, since it doesn't happen with other host names that
> only resolve to one address.  However, fe-connect.c claims:
>
>    /*
>     * Try to initiate a connection to one of the addresses
>     * returned by pg_getaddrinfo_all().  conn->addr_cur is the
>     * next one to try. We fail when we run out of addresses
>     * (reporting the error returned for the *last* alternative,
>     * which may not be what users expect :-().
>     */

That comment is out of date. I implemented the "keep all error
messages and append them to each other" feature to make sure it didn't
throw away the interesting error message and replaced it with a
generic one later, must've missed that comment - at least it should be
changed. And I agree it's not very friendly in this specific case - I
wonder if we should log it as "localhost (127.0.0.1) and "localhost
(::1)" (and similar for any other case that returns more than one
address).

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-10-14 16:27:29
Message-ID: 1287073628-sup-8602@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Magnus Hagander's message of jue oct 14 02:30:36 -0300 2010:

> And I agree it's not very friendly in this specific case - I
> wonder if we should log it as "localhost (127.0.0.1) and "localhost
> (::1)" (and similar for any other case that returns more than one
> address).

+1

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-10-14 17:03:26
Message-ID: 1287075806.9532.7.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On tor, 2010-10-14 at 07:30 +0200, Magnus Hagander wrote:
> And I agree it's not very friendly in this specific case - I
> wonder if we should log it as "localhost (127.0.0.1) and "localhost
> (::1)" (and similar for any other case that returns more than one
> address).

That looks good.


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-11-12 01:54:17
Message-ID: 201011120154.oAC1sHa22085@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On tor, 2010-10-14 at 07:30 +0200, Magnus Hagander wrote:
> > And I agree it's not very friendly in this specific case - I
> > wonder if we should log it as "localhost (127.0.0.1) and "localhost
> > (::1)" (and similar for any other case that returns more than one
> > address).
>
> That looks good.

I have developed the attached patch to report whether IPv4 or IPv6 are
being used. I could not find the numeric value as alwasy populated, and
this seems clearer too:

$ pql -h localhost test
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (IPv4) and accepting
TCP/IP connections on port 5432?

$ psql -h 127.0.0.1 test
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" (IPv4) and accepting
TCP/IP connections on port 5432?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/pgpatches/libpq_ipv6 text/x-diff 1.2 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-11-12 04:57:09
Message-ID: 29130.1289537829@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> I have developed the attached patch to report whether IPv4 or IPv6 are
> being used.

What's the use of that exactly? It doesn't really respond to Peter's
concern, I think.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-11-12 14:02:40
Message-ID: 201011121402.oACE2e227080@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > I have developed the attached patch to report whether IPv4 or IPv6 are
> > being used.
>
> What's the use of that exactly? It doesn't really respond to Peter's
> concern, I think.

Peter liked:

> And I agree it's not very friendly in this specific case - I
> wonder if we should log it as "localhost (127.0.0.1) and "localhost
> (::1)" (and similar for any other case that returns more than one
> address).

What this will show is:

localhost (IPv4)
localhost (IPv6)

Is that good? I can't figure out how to do ::1 because when you supply
a host _name_, there is no reverse mapping done. Looking at the code,
we test for a host name, then a host ip, and don't assume they are both
set.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-11-13 13:35:54
Message-ID: AANLkTimCc_1oodefPYseaRP=Kw5EUGL6vBKb1iSn9mQ1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Nov 12, 2010 at 15:02, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Tom Lane wrote:
>> Bruce Momjian <bruce(at)momjian(dot)us> writes:
>> > I have developed the attached patch to report whether IPv4 or IPv6 are
>> > being used.
>>
>> What's the use of that exactly?  It doesn't really respond to Peter's
>> concern, I think.
>
> Peter liked:
>
>> And I agree it's not very friendly in this specific case - I
>> wonder if we should log it as "localhost (127.0.0.1) and "localhost
>> (::1)" (and similar for any other case that returns more than one
>> address).
>
> What this will show is:
>
>        localhost (IPv4)
>        localhost (IPv6)
>
> Is that good?  I can't figure out how to do ::1 because when you supply
> a host _name_, there is no reverse mapping done.  Looking at the code,
> we test for a host name, then a host ip, and don't assume they are both
> set.

The address is in conn->raddr, no? When you've put in a host name, we
do a forward lookup, so conn->raddr should contain ::1 already? You
only need the reverse mapping to get the "localhost" part, if I read
the code correctly?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: duplicate connection failure messages
Date: 2010-11-14 01:36:31
Message-ID: 201011140136.oAE1aVj02894@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Magnus Hagander wrote:
> On Fri, Nov 12, 2010 at 15:02, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> > Tom Lane wrote:
> >> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> >> > I have developed the attached patch to report whether IPv4 or IPv6 are
> >> > being used.
> >>
> >> What's the use of that exactly? ?It doesn't really respond to Peter's
> >> concern, I think.
> >
> > Peter liked:
> >
> >> And I agree it's not very friendly in this specific case - I
> >> wonder if we should log it as "localhost (127.0.0.1) and "localhost
> >> (::1)" (and similar for any other case that returns more than one
> >> address).
> >
> > What this will show is:
> >
> > ? ? ? ?localhost (IPv4)
> > ? ? ? ?localhost (IPv6)
> >
> > Is that good? ?I can't figure out how to do ::1 because when you supply
> > a host _name_, there is no reverse mapping done. ?Looking at the code,
> > we test for a host name, then a host ip, and don't assume they are both
> > set.
>
> The address is in conn->raddr, no? When you've put in a host name, we
> do a forward lookup, so conn->raddr should contain ::1 already? You
> only need the reverse mapping to get the "localhost" part, if I read
> the code correctly?

OK, I found out how to get the IP address with the attached patch. The
problem is that only pghost is set, never pghostaddr. I am not even
sure how that would get set for this code because my tests show it is
not:

$ psql -h localhost test
pghost = localhost
--> pghostaddr = (null)
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?

$ psql -h 127.0.0.1 test
pghost = 127.0.0.1
pghostaddr = (null)
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

To get this to work, I compared pghost with the raddr value, and printed
the IP address if it was not already printed. There is still a problem
about threading that I can fix.

Is this what we want?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/pgpatches/libpq_ipv6_2 text/x-diff 1.7 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-15 14:34:38
Message-ID: 1289831591-sup-2568@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Bruce Momjian's message of sáb nov 13 22:36:31 -0300 2010:

> OK, I found out how to get the IP address with the attached patch. The
> problem is that only pghost is set, never pghostaddr. I am not even
> sure how that would get set for this code because my tests show it is
> not:

This doesn't work for IPv6 addresses, though.

pghostaddr is specified by the user on the command line as an
optimization to avoid DNS lookups IIRC, which is why you don't see the
code setting it.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-17 16:04:46
Message-ID: 201011171604.oAHG4kE23254@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of sb nov 13 22:36:31 -0300 2010:
>
> > OK, I found out how to get the IP address with the attached patch. The
> > problem is that only pghost is set, never pghostaddr. I am not even
> > sure how that would get set for this code because my tests show it is
> > not:
>
> This doesn't work for IPv6 addresses, though.
>
> pghostaddr is specified by the user on the command line as an
> optimization to avoid DNS lookups IIRC, which is why you don't see the
> code setting it.

OK, I doubt we want to add complexity to improve this, so I see our
options as:

o ignore the problem
o display IPv4/IPv6 labels
o display only an IPv6 label
o something else

Comments?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-18 15:07:49
Message-ID: 1290092783-sup-68@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Bruce Momjian's message of mié nov 17 13:04:46 -0300 2010:

> OK, I doubt we want to add complexity to improve this, so I see our
> options as:
>
> o ignore the problem
> o display IPv4/IPv6 labels
> o display only an IPv6 label
> o something else

I think we should use inet_ntop where available to print the address.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 03:17:59
Message-ID: 201011190317.oAJ3HxP12938@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of mi nov 17 13:04:46 -0300 2010:
>
> > OK, I doubt we want to add complexity to improve this, so I see our
> > options as:
> >
> > o ignore the problem
> > o display IPv4/IPv6 labels
> > o display only an IPv6 label
> > o something else
>
> I think we should use inet_ntop where available to print the address.

Good idea because inet_ntop() is thread-safe. Does that work on IPv6?
You indicated that inet_ntoa() does not.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 03:21:12
Message-ID: 201011190321.oAJ3LCX13564@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of mi nov 17 13:04:46 -0300 2010:
>
> > OK, I doubt we want to add complexity to improve this, so I see our
> > options as:
> >
> > o ignore the problem
> > o display IPv4/IPv6 labels
> > o display only an IPv6 label
> > o something else
>
> I think we should use inet_ntop where available to print the address.

FYI, I see we use inet_ntoa() in getaddrinfo.c. That is not thread-safe
and I should replace it with inet_ntop().

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 15:22:31
Message-ID: 1290180016-sup-2630@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Bruce Momjian's message of vie nov 19 00:17:59 -0300 2010:
> Alvaro Herrera wrote:
> > Excerpts from Bruce Momjian's message of mi nov 17 13:04:46 -0300 2010:
> >
> > > OK, I doubt we want to add complexity to improve this, so I see our
> > > options as:
> > >
> > > o ignore the problem
> > > o display IPv4/IPv6 labels
> > > o display only an IPv6 label
> > > o something else
> >
> > I think we should use inet_ntop where available to print the address.
>
> Good idea because inet_ntop() is thread-safe. Does that work on IPv6?
> You indicated that inet_ntoa() does not.

According to opengroup.org, IPv6 should work if the underlying libraries
support it, whereas inet_ntoa explicitely does not.
http://www.opengroup.org/onlinepubs/009695399/functions/inet_ntop.html
http://www.opengroup.org/onlinepubs/009695399/functions/inet_addr.html

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 15:58:03
Message-ID: 318.1290182283@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Excerpts from Bruce Momjian's message of vie nov 19 00:17:59 -0300 2010:
>> Alvaro Herrera wrote:
>>> I think we should use inet_ntop where available to print the address.
>>
>> Good idea because inet_ntop() is thread-safe. Does that work on IPv6?
>> You indicated that inet_ntoa() does not.

> According to opengroup.org, IPv6 should work if the underlying libraries
> support it, whereas inet_ntoa explicitely does not.
> http://www.opengroup.org/onlinepubs/009695399/functions/inet_ntop.html
> http://www.opengroup.org/onlinepubs/009695399/functions/inet_addr.html

I get the impression that you guys have forgotten the existence of
src/backend/utils/adt/inet_net_ntop.c

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 19:43:33
Message-ID: 201011191943.oAJJhXc17187@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> > Excerpts from Bruce Momjian's message of vie nov 19 00:17:59 -0300 2010:
> >> Alvaro Herrera wrote:
> >>> I think we should use inet_ntop where available to print the address.
> >>
> >> Good idea because inet_ntop() is thread-safe. Does that work on IPv6?
> >> You indicated that inet_ntoa() does not.
>
> > According to opengroup.org, IPv6 should work if the underlying libraries
> > support it, whereas inet_ntoa explicitely does not.
> > http://www.opengroup.org/onlinepubs/009695399/functions/inet_ntop.html
> > http://www.opengroup.org/onlinepubs/009695399/functions/inet_addr.html
>
> I get the impression that you guys have forgotten the existence of
> src/backend/utils/adt/inet_net_ntop.c

Yeah, that is nice, but we are calling this from libpq, not the backend.
Let me work up a patch.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 20:05:17
Message-ID: 1290196912-sup-8910@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Bruce Momjian's message of vie nov 19 16:43:33 -0300 2010:
> Tom Lane wrote:

> > I get the impression that you guys have forgotten the existence of
> > src/backend/utils/adt/inet_net_ntop.c
>
> Yeah, that is nice, but we are calling this from libpq, not the backend.
> Let me work up a patch.

Actually the code seems agnostic (no ereport, palloc etc) so maybe it
could just be moved to src/port.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 20:10:17
Message-ID: 201011192010.oAJKAHd29662@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of vie nov 19 16:43:33 -0300 2010:
> > Tom Lane wrote:
>
> > > I get the impression that you guys have forgotten the existence of
> > > src/backend/utils/adt/inet_net_ntop.c
> >
> > Yeah, that is nice, but we are calling this from libpq, not the backend.
> > Let me work up a patch.
>
> Actually the code seems agnostic (no ereport, palloc etc) so maybe it
> could just be moved to src/port.

I was wondering that. I am unclear if we need it though --- can we not
assume inet_ntop() exists on all systems? We assumed inet_ntoa() did.
Of course, the buildfarm will tell us.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-19 22:56:12
Message-ID: 17897.1290207372@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> I was wondering that. I am unclear if we need it though --- can we not
> assume inet_ntop() exists on all systems? We assumed inet_ntoa() did.

The Single Unix Spec includes inet_ntoa but not inet_ntop.

> Of course, the buildfarm will tell us.

The buildfarm unfortunately contains only a subset of the platforms
we care about. I don't think this problem is large enough to justify
taking a portability risk by depending on non-SUS library functions.

If you want to do this, please do it as suggested previously, ie depend
on the copy of the code we have internally.

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-20 20:43:29
Message-ID: 201011202043.oAKKhTs01861@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > I was wondering that. I am unclear if we need it though --- can we not
> > assume inet_ntop() exists on all systems? We assumed inet_ntoa() did.
>
> The Single Unix Spec includes inet_ntoa but not inet_ntop.
>
> > Of course, the buildfarm will tell us.
>
> The buildfarm unfortunately contains only a subset of the platforms
> we care about. I don't think this problem is large enough to justify
> taking a portability risk by depending on non-SUS library functions.
>
> If you want to do this, please do it as suggested previously, ie depend
> on the copy of the code we have internally.

I assume you are suggesting to use our inet_net_ntop() even if the
system has inet_ntop().

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-20 21:08:56
Message-ID: 4208.1290287336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> I assume you are suggesting to use our inet_net_ntop() even if the
> system has inet_ntop().

If you're going to have code to do the former, it doesn't seem to be
worth the trouble to also have code that does the latter ...

regards, tom lane


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-20 23:07:56
Message-ID: 201011202307.oAKN7vl13470@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > I assume you are suggesting to use our inet_net_ntop() even if the
> > system has inet_ntop().
>
> If you're going to have code to do the former, it doesn't seem to be
> worth the trouble to also have code that does the latter ...

OK, we will not call inet_ntop() at all. I moved the CIDR part of
adt/inet_net_ntop.c into adt/inet_cidr_ntop.c, and moved the remaining
"net" part to /port/inet_net_ntop.c.

I then changed all uses of inet_ntoa to use inet_net_ntop(). While this
churn would perhaps not be warranted just to allow for better error
messages, I found pg_getaddrinfo_all() being called from
libpq::connectDBStart(), which makes it not thread-safe. I am not
excited about backpatching it but it is a threading bug.

The output is as expected:

$ psql -h localhost test
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
$ psql -h 127.0.0.1 test
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/pgpatches/libpq_ipv6_v4 text/x-diff 34.9 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-24 22:04:30
Message-ID: 201011242204.oAOM4UM25312@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > > I assume you are suggesting to use our inet_net_ntop() even if the
> > > system has inet_ntop().
> >
> > If you're going to have code to do the former, it doesn't seem to be
> > worth the trouble to also have code that does the latter ...
>
> OK, we will not call inet_ntop() at all. I moved the CIDR part of
> adt/inet_net_ntop.c into adt/inet_cidr_ntop.c, and moved the remaining
> "net" part to /port/inet_net_ntop.c.
>
> I then changed all uses of inet_ntoa to use inet_net_ntop(). While this
> churn would perhaps not be warranted just to allow for better error
> messages, I found pg_getaddrinfo_all() being called from
> libpq::connectDBStart(), which makes it not thread-safe. I am not
> excited about backpatching it but it is a threading bug.
>
> The output is as expected:
>
> $ psql -h localhost test
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 5432?
> $ psql -h 127.0.0.1 test
> psql: could not connect to server: Connection refused
> Is the server running on host "127.0.0.1" and accepting
> TCP/IP connections on port 5432?

Applied.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-25 00:41:47
Message-ID: 1290645549-sup-4133@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Bruce Momjian's message of mié nov 24 19:04:30 -0300 2010:
> Bruce Momjian wrote:

> > OK, we will not call inet_ntop() at all. I moved the CIDR part of
> > adt/inet_net_ntop.c into adt/inet_cidr_ntop.c, and moved the remaining
> > "net" part to /port/inet_net_ntop.c.

> Applied.

This broke dugong in the ecpg tests.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-25 03:00:22
Message-ID: 201011250300.oAP30MI19253@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Bruce Momjian's message of nov 24 19:04:30 -0300 2010:
> > Bruce Momjian wrote:
>
> > > OK, we will not call inet_ntop() at all. I moved the CIDR part of
> > > adt/inet_net_ntop.c into adt/inet_cidr_ntop.c, and moved the remaining
> > > "net" part to /port/inet_net_ntop.c.
>
> > Applied.
>
> This broke dugong in the ecpg tests.

I stopped checking the build page after a few hours, but I see the
failure now.

I have reviewed the libpq Makefile and I believe I am now properly added
port/inet_net_ntop.c. I improved the comments as well.

Patch attached and applied. Thansk for the heads-up.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 2.4 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 14:06:24
Message-ID: 1290780384.5294.3.camel@fsopti579.F-Secure.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On lör, 2010-11-20 at 18:07 -0500, Bruce Momjian wrote:
> The output is as expected:
>
> $ psql -h localhost test
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 5432?
> $ psql -h 127.0.0.1 test
> psql: could not connect to server: Connection refused
> Is the server running on host "127.0.0.1" and accepting
> TCP/IP connections on port 5432?

Thanks for working on this. However, the example I posted at the
beginning of this thread now does this:

$ ./psql -p 55555 -h localhost
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (???) and accepting
TCP/IP connections on port 55555?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 55555?

The "???" should presumably be "::1".

Also, this comment should be updated:

/*
* Try to initiate a connection to one of the addresses
* returned by pg_getaddrinfo_all(). conn->addr_cur is the
* next one to try. We fail when we run out of addresses
* (reporting the error returned for the *last* alternative,
* which may not be what users expect :-().
*/


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 14:52:30
Message-ID: 1290783063-sup-8271@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Excerpts from Peter Eisentraut's message of vie nov 26 11:06:24 -0300 2010:

> Thanks for working on this. However, the example I posted at the
> beginning of this thread now does this:
>
> $ ./psql -p 55555 -h localhost
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (???) and accepting
> TCP/IP connections on port 55555?

Shouldn't connectFailureMessage receive addr_cur as parameter?
Otherwise it's not clear that it's getting the right params to report.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 16:53:23
Message-ID: 201011261653.oAQGrOm15841@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On l?r, 2010-11-20 at 18:07 -0500, Bruce Momjian wrote:
> > The output is as expected:
> >
> > $ psql -h localhost test
> > psql: could not connect to server: Connection refused
> > Is the server running on host "localhost" (127.0.0.1) and accepting
> > TCP/IP connections on port 5432?
> > $ psql -h 127.0.0.1 test
> > psql: could not connect to server: Connection refused
> > Is the server running on host "127.0.0.1" and accepting
> > TCP/IP connections on port 5432?
>
> Thanks for working on this. However, the example I posted at the
> beginning of this thread now does this:
>
> $ ./psql -p 55555 -h localhost
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (???) and accepting
> TCP/IP connections on port 55555?
> could not connect to server: Connection refused
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 55555?
>
> The "???" should presumably be "::1".

OK, I updated the code to always use cur_addr in the code --- let me
know if that doesn't fix it.

> Also, this comment should be updated:
>
> /*
> * Try to initiate a connection to one of the addresses
> * returned by pg_getaddrinfo_all(). conn->addr_cur is the
> * next one to try. We fail when we run out of addresses
> * (reporting the error returned for the *last* alternative,
> * which may not be what users expect :-().
> */

Thanks, comment udpated. It was wrong even before because we were
reporting all failures even before I Started.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 1.3 KB

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 16:53:59
Message-ID: 201011261653.oAQGrxw15870@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> Excerpts from Peter Eisentraut's message of vie nov 26 11:06:24 -0300 2010:
>
> > Thanks for working on this. However, the example I posted at the
> > beginning of this thread now does this:
> >
> > $ ./psql -p 55555 -h localhost
> > psql: could not connect to server: Connection refused
> > Is the server running on host "localhost" (???) and accepting
> > TCP/IP connections on port 55555?
>
> Shouldn't connectFailureMessage receive addr_cur as parameter?
> Otherwise it's not clear that it's getting the right params to report.

I am passing conn so I changed the code to always use addr_cur.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 18:14:07
Message-ID: 1290795247.12170.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> OK, I updated the code to always use cur_addr in the code --- let me
> know if that doesn't fix it.

Now it's even more wrong:

psql: could not connect to server: Connection refused
Is the server running on host "localhost" (???) and accepting
TCP/IP connections on port 55555?
could not connect to server: Connection refused
Is the server running on host "localhost" (232.106.56.8) and accepting
TCP/IP connections on port 55555?


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 18:27:22
Message-ID: 201011261827.oAQIRMn16679@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> > OK, I updated the code to always use cur_addr in the code --- let me
> > know if that doesn't fix it.
>
> Now it's even more wrong:
>
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (???) and accepting
> TCP/IP connections on port 55555?
> could not connect to server: Connection refused
> Is the server running on host "localhost" (232.106.56.8) and accepting
> TCP/IP connections on port 55555?

Yep, even worse. I have applied the attached patch, which gives me the
right IPv4 value. I can't test IPv6.

I am finding the sock_addr structures confusing.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/diff text/x-diff 1.3 KB

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 19:54:24
Message-ID: 1290801264.12170.2.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On fre, 2010-11-26 at 13:27 -0500, Bruce Momjian wrote:
> Peter Eisentraut wrote:
> > On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> > > OK, I updated the code to always use cur_addr in the code --- let me
> > > know if that doesn't fix it.
> >
> > Now it's even more wrong:
> >
> > psql: could not connect to server: Connection refused
> > Is the server running on host "localhost" (???) and accepting
> > TCP/IP connections on port 55555?
> > could not connect to server: Connection refused
> > Is the server running on host "localhost" (232.106.56.8) and accepting
> > TCP/IP connections on port 55555?
>
> Yep, even worse. I have applied the attached patch, which gives me the
> right IPv4 value. I can't test IPv6.

We're back to

psql: could not connect to server: Connection refused
Is the server running on host "localhost" (???) and accepting
TCP/IP connections on port 55555?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 55555?


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 20:00:02
Message-ID: 201011262000.oAQK02D10246@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut wrote:
> On fre, 2010-11-26 at 13:27 -0500, Bruce Momjian wrote:
> > Peter Eisentraut wrote:
> > > On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> > > > OK, I updated the code to always use cur_addr in the code --- let me
> > > > know if that doesn't fix it.
> > >
> > > Now it's even more wrong:
> > >
> > > psql: could not connect to server: Connection refused
> > > Is the server running on host "localhost" (???) and accepting
> > > TCP/IP connections on port 55555?
> > > could not connect to server: Connection refused
> > > Is the server running on host "localhost" (232.106.56.8) and accepting
> > > TCP/IP connections on port 55555?
> >
> > Yep, even worse. I have applied the attached patch, which gives me the
> > right IPv4 value. I can't test IPv6.
>
> We're back to
>
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (???) and accepting
> TCP/IP connections on port 55555?
> could not connect to server: Connection refused
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 55555?

OK, good. :-O I just realize I can easily test this on Ubuntu so let
me get that working now.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 23:16:11
Message-ID: 201011262316.oAQNGBQ05950@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian wrote:
> Peter Eisentraut wrote:
> > On fre, 2010-11-26 at 13:27 -0500, Bruce Momjian wrote:
> > > Peter Eisentraut wrote:
> > > > On fre, 2010-11-26 at 11:53 -0500, Bruce Momjian wrote:
> > > > > OK, I updated the code to always use cur_addr in the code --- let me
> > > > > know if that doesn't fix it.
> > > >
> > > > Now it's even more wrong:
> > > >
> > > > psql: could not connect to server: Connection refused
> > > > Is the server running on host "localhost" (???) and accepting
> > > > TCP/IP connections on port 55555?
> > > > could not connect to server: Connection refused
> > > > Is the server running on host "localhost" (232.106.56.8) and accepting
> > > > TCP/IP connections on port 55555?
> > >
> > > Yep, even worse. I have applied the attached patch, which gives me the
> > > right IPv4 value. I can't test IPv6.
> >
> > We're back to
> >
> > psql: could not connect to server: Connection refused
> > Is the server running on host "localhost" (???) and accepting
> > TCP/IP connections on port 55555?
> > could not connect to server: Connection refused
> > Is the server running on host "localhost" (127.0.0.1) and accepting
> > TCP/IP connections on port 55555?
>
> OK, good. :-O I just realize I can easily test this on Ubuntu so let
> me get that working now.

OK, Tom and I both found the problem --- our data type assumed INET6 was
INET + 1, while libc had other ideas. Here is the new, I guess correct,
output from Ubuntu:

$ /usr/local/pgsql/bin/psql -h localhost test
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and
accepting
TCP/IP connections on port 5432?

Is "::" correct?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-26 23:53:19
Message-ID: 6025.1290815599@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <bruce(at)momjian(dot)us> writes:
> Is "::" correct?

I don't think so ... I get this, even sillier, response:

$ psql -h ::1 -p 5433 regression
psql: could not connect to server: Connection refused
Is the server running on host "::1" (::) and accepting
TCP/IP connections on port 5433?

Seems like a logic bug in inet_net_ntop_ipv6. Before we waste mental
effort finding it for ourselves, has anyone checked for fixes in the
upstream code lately?

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Magnus Hagander <magnus(at)hagander(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: duplicate connection failure messages
Date: 2010-11-27 00:18:04
Message-ID: 6622.1290817084@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wrote:
> Seems like a logic bug in inet_net_ntop_ipv6.

um ... no, it's connectFailureMessage's fault.

regards, tom lane