Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-24 Thread Bruce Momjian

Already applied by Tom.  Thanks.

---


Kurt Roeckx wrote:
 On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:
  From: Kurt Roeckx [EMAIL PROTECTED]
  Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
  argument
  Date: Sun, 6 Jul 2003 18:44:35 +0200
  
  ;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
  ;;;  Try the attached patch instead.
  ;;; 
  ;;; Oops, that one was a little broken. I change it.
  ;;; 
  ;;; Try the attached one instead.
  
  I tried the newest one.
 
 I did some investigation on a redhat 6.0.  It seems getaddrinfo
 is really broken.
 
 It returns an AF_INET socket, but it doesn't say it should be of
 socket type SOCK_DGRAM.  It also returns an AF_UNIX socket and
 for that it sets the socktype correct, but we don't want to use
 the AF_UNIX one.
 
 I'm going to assume that Mac Os X is broken in the same way.
 
 Here is a new patch.
 
 
 Kurt
 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 8: explain analyze is your friend

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-20 Thread Bruce Momjian

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---


Kurt Roeckx wrote:
 On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:
  From: Kurt Roeckx [EMAIL PROTECTED]
  Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
  argument
  Date: Sun, 6 Jul 2003 18:44:35 +0200
  
  ;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
  ;;;  Try the attached patch instead.
  ;;; 
  ;;; Oops, that one was a little broken. I change it.
  ;;; 
  ;;; Try the attached one instead.
  
  I tried the newest one.
 
 I did some investigation on a redhat 6.0.  It seems getaddrinfo
 is really broken.
 
 It returns an AF_INET socket, but it doesn't say it should be of
 socket type SOCK_DGRAM.  It also returns an AF_UNIX socket and
 for that it sets the socktype correct, but we don't want to use
 the AF_UNIX one.
 
 I'm going to assume that Mac Os X is broken in the same way.
 
 Here is a new patch.
 
 
 Kurt
 

[ Attachment, skipping... ]

 
 ---(end of broadcast)---
 TIP 8: explain analyze is your friend

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-09 Thread qhwt
Hello,

 On Mon, Jul 07, 2003 at 12:55:06AM +0900, [EMAIL PROTECTED] wrote:
  
  When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
  first one being IPv6 one, and the second one is IPv4 one, even if
  IPv6 support is not compiled in the kernel(this is true at least on
  my FreeBSD box).

Sorry, this turned out to be bogus; AI_ADDRCONFIG flag was already present as
early as FreeBSD 4.3-RELEASE, but I forgot adding the flag in my test code.
The flag is not documented in the getaddrinfo(3) man page.

On Sun, Jul 06, 2003 at 06:35:52PM +0200, Kurt Roeckx wrote:
 And that is why you have AI_ADDRCONFIG, which seems to be broken
 for him.

I doubt RedHat 6 or MacOS X really support AI_ADDRCONFIG. Is it actually
defined somewhere in the system headers? Anyway it seems like its absence
is hidden by the following lines:

src/include/libpq/pqcomm.h:
85-/* Some systems don't have it, so default it to 0 so it doesn't
86- * have any effect on those systems. */
87:#ifndef  AI_ADDRCONFIG
88:#define  AI_ADDRCONFIG 0
89-#endif

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-09 Thread Kenji Sugita
From: Kurt Roeckx [EMAIL PROTECTED]
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;;  Try the attached patch instead.
;;; 
;;; Oops, that one was a little broken. I change it.
;;; 
;;; Try the attached one instead.

I tried the newest one.

  Red Hat 6.2
$ postmaster
# Waiting forever

$ top
 11:24am  up 276 days, 14:12,  2 users,  load average: 0.90, 0.66, 0.35
46 processes: 44 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 49.6% user,  0.8% system,  0.0% nice, 49.5% idle
Mem:  2009220K av, 1544312K used,  464908K free,   37792K shrd, 1402556K buff
Swap:  265064K av,4024K used,  261040K free   78444K cached

  PID USER PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
12074 sugita10   0  1668 1668  1328 R   0 99.2  0.0   1:00 postmaster
..

  Mac OS X 10.2.6
$ postmaster
2003-07-08 11:48:32 [1512] LOG:  PGSTAT: socket() failed: Protocol not supported


Kenji Sugita  

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-08 Thread Kurt Roeckx
On Tue, Jul 08, 2003 at 12:34:19PM +0900, Kenji Sugita wrote:
 From: Kurt Roeckx [EMAIL PROTECTED]
 Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
 argument
 Date: Sun, 6 Jul 2003 18:44:35 +0200
 
 ;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
 ;;;  Try the attached patch instead.
 ;;; 
 ;;; Oops, that one was a little broken. I change it.
 ;;; 
 ;;; Try the attached one instead.
 
 I tried the newest one.

I did some investigation on a redhat 6.0.  It seems getaddrinfo
is really broken.

It returns an AF_INET socket, but it doesn't say it should be of
socket type SOCK_DGRAM.  It also returns an AF_UNIX socket and
for that it sets the socktype correct, but we don't want to use
the AF_UNIX one.

I'm going to assume that Mac Os X is broken in the same way.

Here is a new patch.


Kurt

Index: ./src/backend/postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c   12 Jun 2003 07:36:51 -  1.37
+++ ./src/backend/postmaster/pgstat.c   8 Jul 2003 20:24:20 -
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
ACCEPT_TYPE_ARG3alen;
-   struct  addrinfo*addr, hints;
+   struct  addrinfo*addrs, *addr, hints;
int ret;
 
/*
@@ -187,16 +187,32 @@
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
hints.ai_next = NULL;
-   ret = getaddrinfo2(localhost, NULL, hints, addr);
-   if (ret || !addr)
+   ret = getaddrinfo2(localhost, NULL, hints, addrs);
+
+   if (ret || !addrs)
{
elog(LOG, PGSTAT: getaddrinfo2() failed: %s,
gai_strerror(ret));
goto startup_failed;
}

-   if ((pgStatSock = socket(addr-ai_family,
-   addr-ai_socktype, addr-ai_protocol))  0)
+   for (addr = addrs; addr; addr = addr-ai_next)
+   {
+#ifdef HAVE_UNIX_SOCKETS
+   /* Skip AF_UNIX sockets. */
+   if (addr-ai_family == AF_UNIX)
+   {
+   continue;
+   }
+#endif
+   if ((pgStatSock = socket(addr-ai_family,
+   SOCK_DGRAM, 0)) = 0)
+   {
+   break;
+   }
+   }
+
+   if (!addr || pgStatSock  0)
{
elog(LOG, PGSTAT: socket() failed: %m);
goto startup_failed;
@@ -211,8 +227,8 @@
elog(LOG, PGSTAT: bind() failed: %m);
goto startup_failed;
}
-   freeaddrinfo2(hints.ai_family, addr);
-   addr = NULL;
+   freeaddrinfo2(hints.ai_family, addrs);
+   addrs = NULL;
 
alen = sizeof(pgStatAddr);
if (getsockname(pgStatSock, (struct sockaddr *)pgStatAddr, alen)  0)
@@ -257,9 +273,9 @@
return;
 
 startup_failed:
-   if (addr)
+   if (addrs)
{
-   freeaddrinfo2(hints.ai_family, addr);
+   freeaddrinfo2(hints.ai_family, addrs);
}
 
if (pgStatSock = 0)
Index: ./src/backend/libpq/pqcomm.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c12 Jun 2003 07:36:51 -  1.157
+++ ./src/backend/libpq/pqcomm.c8 Jul 2003 20:24:35 -
@@ -216,7 +216,7 @@
/* Initialize hint structure */
MemSet(hint, 0, sizeof(hint));
hint.ai_family = family;
-   hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+   hint.ai_flags = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS
@@ -266,8 +266,7 @@
/* Nothing found. */
break;
}
-   if ((fd = socket(addr-ai_family, addr-ai_socktype,
-   addr-ai_protocol))  0)
+   if ((fd = socket(addr-ai_family, SOCK_STREAM, 0))  0)
{
elog(LOG, server socket failure: socket(): %s,
 strerror(errno));

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-08 Thread Kenji Sugita
From: Kurt Roeckx [EMAIL PROTECTED]
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:
Date: Tue, 8 Jul 2003 22:25:44 +0200

;;;  ;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;;  ;;;  Try the attached patch instead.
;;;  ;;; 
;;;  ;;; Oops, that one was a little broken. I change it.
;;;  ;;; 
;;;  ;;; Try the attached one instead.
;;;  
;;;  I tried the newest one.
;;; 
;;; I did some investigation on a redhat 6.0.  It seems getaddrinfo
;;; is really broken.



;;; It returns an AF_INET socket, but it doesn't say it should be of
;;; socket type SOCK_DGRAM.  

I pointed it in the first post. Rturned type is not SOCK_DGRAM.

;;;  It also returns an AF_UNIX socket and
;;; for that it sets the socktype correct, but we don't want to use
;;; the AF_UNIX one.
;;; 
;;; I'm going to assume that Mac Os X is broken in the same way.
;;; 
;;; Here is a new patch.

It works on both platforms.

Thanks.


Kenji Sugita  


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-07 Thread Kenji Sugita
From: Kurt Roeckx [EMAIL PROTECTED]
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
argument
Date: Sun, 6 Jul 2003 18:44:35 +0200

;;; On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
;;;  Try the attached patch instead.
;;; 
;;; Oops, that one was a little broken. I change it.
;;; 
;;; Try the attached one instead.

I tried the newest one.

  Red Hat 6.2
$ postmaster
# Waiting forever

$ top
 11:24am  up 276 days, 14:12,  2 users,  load average: 0.90, 0.66, 0.35
46 processes: 44 sleeping, 2 running, 0 zombie, 0 stopped
CPU states: 49.6% user,  0.8% system,  0.0% nice, 49.5% idle
Mem:  2009220K av, 1544312K used,  464908K free,   37792K shrd, 1402556K buff
Swap:  265064K av,4024K used,  261040K free   78444K cached

  PID USER PRI  NI  SIZE  RSS SHARE STAT  LIB %CPU %MEM   TIME COMMAND
12074 sugita10   0  1668 1668  1328 R   0 99.2  0.0   1:00 postmaster
..

  Mac OS X 10.2.6
$ postmaster
2003-07-08 11:48:32 [1512] LOG:  PGSTAT: socket() failed: Protocol not supported


Kenji Sugita  

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-06 Thread qhwt
On Mon, Jul 07, 2003 at 12:38:57AM +0900, [EMAIL PROTECTED] wrote:
 Hi,
 
 On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
  It seems that a value of addr-ai_socktype returned by getaddrinfo in
  pg_stat.c is not SOCK_DGRAM.
 
 Please try the following untested patch:

No, please disregard the previous mail and try this one.

When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
first one being IPv6 one, and the second one is IPv4 one, even if
IPv6 support is not compiled in the kernel(this is true at least on
my FreeBSD box).

--- pgstat.cThu Jun 12 16:36:51 2003
+++ pgstat.cMon Jul  7 00:49:07 2003
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
ACCEPT_TYPE_ARG3alen;
-   struct  addrinfo*addr, hints;
+   struct  addrinfo*addr0, addr, hints;
int ret;
 
/*
@@ -187,17 +187,19 @@
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
hints.ai_next = NULL;
-   ret = getaddrinfo2(localhost, NULL, hints, addr);
-   if (ret || !addr)
+   ret = getaddrinfo2(localhost, NULL, hints, addr0);
+   if (ret || !addr0)
{
elog(LOG, PGSTAT: getaddrinfo2() failed: %s,
gai_strerror(ret));
goto startup_failed;
}
-   
-   if ((pgStatSock = socket(addr-ai_family,
-   addr-ai_socktype, addr-ai_protocol))  0)
-   {
+
+   for (addr = addr0; addr != NULL; addr = addr-ai_next)
+   if ((pgStatSock = socket(addr-ai_family,
+   addr-ai_socktype, addr-ai_protocol)) = 0)
+   break;
+   if (pgStatSock  0) {
elog(LOG, PGSTAT: socket() failed: %m);
goto startup_failed;
}
@@ -211,8 +213,8 @@
elog(LOG, PGSTAT: bind() failed: %m);
goto startup_failed;
}
-   freeaddrinfo2(hints.ai_family, addr);
-   addr = NULL;
+   freeaddrinfo2(hints.ai_family, addr0);
+   addr0 = addr = NULL;
 
alen = sizeof(pgStatAddr);
if (getsockname(pgStatSock, (struct sockaddr *)pgStatAddr, alen)  0)



---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-06 Thread Kurt Roeckx
On Mon, Jul 07, 2003 at 12:38:57AM +0900, [EMAIL PROTECTED] wrote:
 
 On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
  It seems that a value of addr-ai_socktype returned by getaddrinfo in
  pg_stat.c is not SOCK_DGRAM.
 
 Please try the following untested patch:
[...]

 + for (; addr != NULL; addr = addr-ai_next)
 + if ((pgStatSock = socket(addr-ai_family,
 + addr-ai_socktype, addr-ai_protocol)) = 0)
 + break;

This will break.  You should use a pointer to the addr, and go
over the list using that.

freeaddrinfo() needs to have the original addr back.

He seems to have 2 problems:
- On Mac OS X getaddrinfo() returns something it shouldn't.
  A patch like that could fix it.
- On Linux Redhat 6.2 (and 6.0) getaddrinfo() seems to have a
  problem with AI_ADDRCONFIG.  Which is also used in
  StreamServerPort().  So he won't be able to listen to any
  socket there either.

Not being able to use AI_ADDRCONFIG is rather annoying, but I
guess if we just try all the returned addresses until 1 works
will have to do.

Try the attached patch instead.


Kurt

Index: ./src/backend/postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c   12 Jun 2003 07:36:51 -  1.37
+++ ./src/backend/postmaster/pgstat.c   6 Jul 2003 16:27:20 -
@@ -146,6 +146,7 @@
 {
ACCEPT_TYPE_ARG3alen;
struct  addrinfo*addr, hints;
+   struct  addrinfo*addrp;
int ret;
 
/*
@@ -188,15 +189,38 @@
hints.ai_canonname = NULL;
hints.ai_next = NULL;
ret = getaddrinfo2(localhost, NULL, hints, addr);
-   if (ret || !addr)
+
+   addrp = addr;
+
+#ifdef HAVE_UNIX_SOCKETS
+   /* Skip AF_UNIX sockets. */
+   if (!ret)
+   {
+   while (addrp  addrp-ai_family == AF_UNIX)
+   {
+   addrp = addrp-ai_next;
+   }
+   }
+#endif
+
+   if (ret || !addrp)
{
elog(LOG, PGSTAT: getaddrinfo2() failed: %s,
gai_strerror(ret));
goto startup_failed;
}
+

-   if ((pgStatSock = socket(addr-ai_family,
-   addr-ai_socktype, addr-ai_protocol))  0)
+   for (; addrp; addrp = addrp-ai_next)
+   {
+   if ((pgStatSock = socket(addrp-ai_family,
+   addrp-ai_socktype, addrp-ai_protocol)) = 0)
+   {
+   break;
+   }
+   }
+
+   if (!addrp)
{
elog(LOG, PGSTAT: socket() failed: %m);
goto startup_failed;
@@ -206,7 +230,7 @@
 * Bind it to a kernel assigned port on localhost and get the assigned
 * port via getsockname().
 */
-   if (bind(pgStatSock, addr-ai_addr, addr-ai_addrlen)  0)
+   if (bind(pgStatSock, addrp-ai_addr, addrp-ai_addrlen)  0)
{
elog(LOG, PGSTAT: bind() failed: %m);
goto startup_failed;
Index: ./src/backend/libpq/pqcomm.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c12 Jun 2003 07:36:51 -  1.157
+++ ./src/backend/libpq/pqcomm.c6 Jul 2003 16:28:01 -
@@ -216,7 +216,7 @@
/* Initialize hint structure */
MemSet(hint, 0, sizeof(hint));
hint.ai_family = family;
-   hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+   hint.ai_flags = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-06 Thread Kurt Roeckx
On Mon, Jul 07, 2003 at 12:55:06AM +0900, [EMAIL PROTECTED] wrote:
 
 When hints.ai_family is PF_UNSPEC, getaddrinfo() returns two entries,
 first one being IPv6 one, and the second one is IPv4 one, even if
 IPv6 support is not compiled in the kernel(this is true at least on
 my FreeBSD box).

And that is why you have AI_ADDRCONFIG, which seems to be broken
for him.


Kurt


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-06 Thread Kurt Roeckx
On Sun, Jul 06, 2003 at 06:30:04PM +0200, Kurt Roeckx wrote:
 Try the attached patch instead.

Oops, that one was a little broken. I change it.

Try the attached one instead.


Kurt

Index: ./src/backend/postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- ./src/backend/postmaster/pgstat.c   12 Jun 2003 07:36:51 -  1.37
+++ ./src/backend/postmaster/pgstat.c   6 Jul 2003 16:42:52 -
@@ -145,7 +145,7 @@
 pgstat_init(void)
 {
ACCEPT_TYPE_ARG3alen;
-   struct  addrinfo*addr, hints;
+   struct  addrinfo*addrs, *addr, hints;
int ret;
 
/*
@@ -187,16 +187,32 @@
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
hints.ai_next = NULL;
-   ret = getaddrinfo2(localhost, NULL, hints, addr);
-   if (ret || !addr)
+   ret = getaddrinfo2(localhost, NULL, hints, addrs);
+
+   if (ret || !addrs)
{
elog(LOG, PGSTAT: getaddrinfo2() failed: %s,
gai_strerror(ret));
goto startup_failed;
}

-   if ((pgStatSock = socket(addr-ai_family,
-   addr-ai_socktype, addr-ai_protocol))  0)
+   for (addr = addrs; addr; addr = addr-ai_next)
+   {
+#ifdef HAVE_UNIX_SOCKETS
+   /* Skip AF_UNIX sockets. */
+   while (addr  addr-ai_family == AF_UNIX)
+   {
+   continue;
+   }
+#endif
+   if ((pgStatSock = socket(addr-ai_family,
+   addr-ai_socktype, addr-ai_protocol)) = 0)
+   {
+   break;
+   }
+   }
+
+   if (!addr || pgStatSock  0)
{
elog(LOG, PGSTAT: socket() failed: %m);
goto startup_failed;
@@ -211,8 +227,8 @@
elog(LOG, PGSTAT: bind() failed: %m);
goto startup_failed;
}
-   freeaddrinfo2(hints.ai_family, addr);
-   addr = NULL;
+   freeaddrinfo2(hints.ai_family, addrs);
+   addrs = NULL;
 
alen = sizeof(pgStatAddr);
if (getsockname(pgStatSock, (struct sockaddr *)pgStatAddr, alen)  0)
@@ -257,9 +273,9 @@
return;
 
 startup_failed:
-   if (addr)
+   if (addrs)
{
-   freeaddrinfo2(hints.ai_family, addr);
+   freeaddrinfo2(hints.ai_family, addrs);
}
 
if (pgStatSock = 0)
Index: ./src/backend/libpq/pqcomm.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/libpq/pqcomm.c,v
retrieving revision 1.157
diff -u -r1.157 pqcomm.c
--- ./src/backend/libpq/pqcomm.c12 Jun 2003 07:36:51 -  1.157
+++ ./src/backend/libpq/pqcomm.c6 Jul 2003 16:42:58 -
@@ -216,7 +216,7 @@
/* Initialize hint structure */
MemSet(hint, 0, sizeof(hint));
hint.ai_family = family;
-   hint.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+   hint.ai_flags = AI_PASSIVE;
hint.ai_socktype = SOCK_STREAM;
 
 #ifdef HAVE_UNIX_SOCKETS

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-03 Thread Kurt Roeckx
On Thu, Jul 03, 2003 at 10:44:31AM +0900, Kenji Sugita wrote:
 
 From: Kurt Roeckx [EMAIL PROTECTED]
 To: Kenji Sugita [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Date: Wed, 2 Jul 2003 19:20:11 +0200
 
 ;;; What system are you running on, and does it have a getaddrinfo()
 ;;; or not?
 
 Red Hat Linux 6.2 and Mac OS X 10.2.6.
[...]
 For Mac OS X it produces LOG:  PGSTAT: socket() failed: Protocol not supported.

This looks a little broken behaviour to me.  My guess is that it
returns an AF_INET6 socket but doesn't support it in the kernel.
In that case with the AI_ADDRCONFIG option it shouldn't have
returned that address.  The question is wether your getaddrinfo()
supports that option, and wether it's working or not.

We can fix this by going over all the returned addresses until
one of the socket() calls works.

We probably should also skip AF_UNIX sockets, since that might
not be want we want.

 $ postmaster (on Red Hat)
 ...
 2003-07-03 10:19:38 [29761] LOG:  XX000: PGSTAT: getaddrinfo2() failed: Name or 
 service not known

That is just evil.  It can't even resolv localhost?  Do you have
a localhost entry in /etc/hosts?

If that's not the problem I see no other way but to use
INADDR_LOOPBACK and in6addr_loopback directly instead, which I
really hate.

 What value shuld be passed to a following socket call with
 addr-ai_socktype?
 
   pgstats.c  
 if ((pgStatSock = socket(addr-ai_family,
 addr-ai_socktype, addr-ai_protocol))  0)
 {
 elog(LOG, PGSTAT: socket() failed: %m);
 goto startup_failed;
 }

The ai_family should be either AF_INET or AF_INET6, ai_socktype
should be SOCK_DGRAM, and ai_protocol 0 or IPPROTO_UDP.



Kurt


---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid

2003-07-02 Thread Bruce Momjian

I don't see any pg_stat.c in the source tree.  Can you show us the exact
line, and perhaps the failure.

---

Kenji Sugita wrote:
 It seems that a value of addr-ai_socktype returned by getaddrinfo in
 pg_stat.c is not SOCK_DGRAM.
 
 
 Kenji Sugita  
 
 
 ---(end of broadcast)---
 TIP 2: you can get off all lists at once with the unregister command
 (send unregister YourEmailAddressHere to [EMAIL PROTECTED])
 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid

2003-07-02 Thread Kurt Roeckx
On Wed, Jul 02, 2003 at 10:06:54AM -0400, Bruce Momjian wrote:
 
 I don't see any pg_stat.c in the source tree.  Can you show us the exact
 line, and perhaps the failure.

He means pgstat.c of course.


Kurt


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-02 Thread Kurt Roeckx
On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
 It seems that a value of addr-ai_socktype returned by getaddrinfo in
 pg_stat.c is not SOCK_DGRAM.

What system are you running on, and does it have a getaddrinfo()
or not?

If I tell getaddrinfo() it should return a SOCK_DGRAM, it can
only mean that getaddrinfo() is broken.


Kurt


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-02 Thread Kurt Roeckx
On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
 It seems that a value of addr-ai_socktype returned by getaddrinfo in
 pg_stat.c is not SOCK_DGRAM.

What do you base this on?

My guess is that it returns an ipv6 address while you do not have
IPv6 support in the kernel.  If that is the case, the attached
patch should fix it.



Kurt

Index: src/backend/postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- src/backend/postmaster/pgstat.c 12 Jun 2003 07:36:51 -  1.37
+++ src/backend/postmaster/pgstat.c 2 Jul 2003 18:34:30 -
@@ -179,7 +179,7 @@
/*
 * Create the UDP socket for sending and receiving statistic messages
 */
-   hints.ai_flags = AI_PASSIVE;
+   hints.ai_flags = AI_PASSIVE | AI_ADDRCONF;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid argument

2003-07-02 Thread Kurt Roeckx
On Wed, Jul 02, 2003 at 08:35:00PM +0200, Kurt Roeckx wrote:
 On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
  It seems that a value of addr-ai_socktype returned by getaddrinfo in
  pg_stat.c is not SOCK_DGRAM.
 
 What do you base this on?
 
 My guess is that it returns an ipv6 address while you do not have
 IPv6 support in the kernel.  If that is the case, the attached
 patch should fix it.
 

Oops typo, fixed in new attachment.


Kurt

Index: src/backend/postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- src/backend/postmaster/pgstat.c 12 Jun 2003 07:36:51 -  1.37
+++ src/backend/postmaster/pgstat.c 2 Jul 2003 18:51:08 -
@@ -179,7 +179,7 @@
/*
 * Create the UDP socket for sending and receiving statistic messages
 */
-   hints.ai_flags = AI_PASSIVE;
+   hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed:

2003-07-02 Thread Kenji Sugita
From: Kurt Roeckx [EMAIL PROTECTED]
To: Kenji Sugita [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Date: Wed, 2 Jul 2003 19:20:11 +0200

;;; What system are you running on, and does it have a getaddrinfo()
;;; or not?

Red Hat Linux and Mac OS X 10.2.6. Both nm libc display getaddrinfo as follows:

$ nm /lib/libc.so.6 | grep getaddrinfo
0009fe3c T getaddrinfo
$ 

$ nm /usr/lib/libc.dylib | grep getaddrinfo
/usr/lib/libc.dylib(getaddrinfo.o):
90037dc0 T _getaddrinfo
 U _getaddrinfo
$

;;; If I tell getaddrinfo() it should return a SOCK_DGRAM, it can
;;; only mean that getaddrinfo() is broken.

What value shuld be passed to a following socket call with addr-ai_socktype?

  pgstats.c  
if ((pgStatSock = socket(addr-ai_family,
addr-ai_socktype, addr-ai_protocol))  0)
{
elog(LOG, PGSTAT: socket() failed: %m);
goto startup_failed;
}

From: Kurt Roeckx [EMAIL PROTECTED]
Subject: Re: [HACKERS] PostgreSQL 7.4devel - LOG: PGSTAT: socket() failed: Invalid 
argument
Date: Wed, 2 Jul 2003 20:52:00 +0200

;;; On Wed, Jul 02, 2003 at 08:35:00PM +0200, Kurt Roeckx wrote:
;;;  On Wed, Jul 02, 2003 at 03:49:19PM +0900, Kenji Sugita wrote:
;;;   It seems that a value of addr-ai_socktype returned by getaddrinfo in
;;;   pg_stat.c is not SOCK_DGRAM.
;;;  
;;;  What do you base this on?

Red Hat Linux 6.2 base.

$ uname -rs   
Linux 2.2.18-0ph1smp
$ 

For Mac OS X it produces LOG:  PGSTAT: socket() failed: Protocol not supported.

;;;  My guess is that it returns an ipv6 address while you do not have
;;;  IPv6 support in the kernel.  If that is the case, the attached
;;;  patch should fix it.
;;;  
;;; 
;;; Oops typo, fixed in new attachment.

I tried it for current build.

Index: postmaster/pgstat.c
===
RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.37
diff -u -r1.37 pgstat.c
--- postmaster/pgstat.c 12 Jun 2003 07:36:51 -  1.37
+++ postmaster/pgstat.c 3 Jul 2003 01:19:05 -
@@ -179,7 +179,7 @@
/*
 * Create the UDP socket for sending and receiving statistic messages
 */
-   hints.ai_flags = AI_PASSIVE;
+   hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = 0;
$ 

And then:

$ postmaster (on Red Hat)
...
2003-07-03 10:19:38 [29761] LOG:  XX000: PGSTAT: getaddrinfo2() failed: Name or 
service not known
LOCATION:  pgstat_init, pgstat.c:193
...
  

Kenji Sugita  

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings