tgl@xxxxxxxxxxxxx (Tom Lane) writes: > Chris Browne <cbbrowne@xxxxxxx> writes: >> tgl@xxxxxxxxxxxxx (Tom Lane) writes: >>> Chris Browne <cbbrowne@xxxxxxx> writes: >>>> (gdb) print addr->ai_addr->sa_data >>>> $18 = "\000\001\177\000\000\001\000\000\000\000\000\000\000" >>> >>> Hmm, that looks a bit odd --- what's the full declaration of structs >>> sockaddr and sockaddr_in on that machine? > >> struct sockaddr { >> uchar_t sa_len; /* total length */ >> sa_family_t sa_family; /* address family */ >> char sa_data[14]; /* actually longer; address value */ >> }; > >> struct sockaddr_in { >> uchar_t sin_len; >> sa_family_t sin_family; >> in_port_t sin_port; >> struct in_addr sin_addr; >> uchar_t sin_zero[8]; >> }; > > So you've got sin_port = 1, which explains the permission-denied > message. Next question is why getaddrinfo is setting it that way > rather than to zero. Is it possible that getaddrinfo is failing > to initialize the field at all, and we're just getting bit by > random pre-existing memory contents? Ok, modifying to force the port value to 0... /* * Create the socket. */ if ((pgStatSock = socket(addr->ai_family, SOCK_DGRAM, 0)) < 0) { ereport(LOG, (errcode_for_socket_access(), errmsg("could not create socket for statistics collector: %m"))); continue; } addr->ai_addr->sa_data[0] = 0; /* cbbrowne: 2006-10-19 */ addr->ai_addr->sa_data[1] = 0; /* cbbrowne: 2006-10-19 */ /* * 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) { ereport(LOG, (errcode_for_socket_access(), errmsg("could not bind socket for statistics collector: %m"))); closesocket(pgStatSock); pgStatSock = -1; continue; } Bad, old binary: pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ /opt/dbs/pgsql813-plTcl-slony115-AIX53-64bit-2006-02-14/bin/pg_ctl -D . start postmaster starting pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ LOG: could not bind socket for statistics collector: Permission denied LOG: disabling statistics collector for lack of working socket LOG: database system was shut down at 2006-10-19 16:18:13 UTC LOG: checkpoint record is at 0/38D3D0 LOG: redo record is at 0/38D3D0; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 565; next OID: 10794 LOG: next MultiXactId: 1; next MultiXactOffset: 0 LOG: database system is ready LOG: transaction ID wrap limit is 2147484146, limited by database "postgres" pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ /opt/dbs/pgsql813-plTcl-slony115-AIX53-64bit-2006-02-14/bin/pg_ctl -D . stop waiting for postmaster to shut down....LOG: received smart shutdown request LOG: shutting down LOG: database system is shut down done pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ /opt/dbs/pgsql815-AIX5300-05-02-64bit-TEST_BUILD/bin/pg_ctl -D . start postmaster starting pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ LOG: could not bind IPv4 socket: Address already in use HINT: Is another postmaster already running on port 9732? If not, wait a few seconds and retry. WARNING: could not create listen socket for "127.0.0.1" LOG: database system was shut down at 2006-10-19 16:25:11 UTC LOG: checkpoint record is at 0/38D470 LOG: redo record is at 0/38D470; undo record is at 0/0; shutdown TRUE LOG: next transaction ID: 565; next OID: 10794 LOG: next MultiXactId: 1; next MultiXactOffset: 0 LOG: database system is ready LOG: transaction ID wrap limit is 2147484146, limited by database "postgres" pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ psql -h localhost -p 9732 postgres Welcome to psql 7.4.12, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit postgres=# begin; BEGIN postgres=# select * from pg_stat_activity ; datid | datname | procpid | usesysid | usename | current_query | query_start | backend_start | client_addr | client_port -------+----------+---------+----------+---------+------------------------------+-------------+-------------------------------+-------------+------------- 10793 | postgres | 352498 | 10 | pgrt | <command string not enabled> | | 2006-10-19 16:25:57.179199+00 | 127.0.0.1 | 34178 (1 row) Something's a bit amok with the listen socket issue, but the stats collector is clearly running: pgrt@xxxxxxxxxxxxxxxxxxxxxxx:/opt/rg/data_rt/scratch $ ps auxww | egrep '([p]ostmaster|[p]ostgres:)' pgrt 373030 0.0 0.0 3480 24996 pts/0 A 16:25:35 0:00 /opt/dbs/pgsql815-AIX5300-05-02-64bit-TEST_BUILD/bin/postmaster -D . pgrt 283052 0.0 0.0 3536 25052 pts/0 A 16:25:35 0:00 postgres: writer process pgrt 1081804 0.0 0.0 3756 25268 pts/0 A 16:25:35 0:00 postgres: stats collector process pgrt 1441812 0.0 0.0 3496 25008 pts/0 A 16:25:35 0:00 postgres: stats buffer process Is there a more elegant way of setting the requested port to 0 than my 2-liner? I expect so... -- let name="cbbrowne" and tld="linuxdatabases.info" in String.concat "@" [name;tld];; http://cbbrowne.com/info/ Thank you for onlining with ITS -- Be sure to patronize us again for your next fix.