Re: Bug? 'psql -l' in pg_ctl?

From: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
To: grasshacker(at)over-yonder(dot)net
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Bug? 'psql -l' in pg_ctl?
Date: 2000-11-27 01:53:04
Message-ID: 20001127105304J.t-ishii@sra.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Er, did anybody notice trouble when starting Postgres if a password has
> been set for user pgsql?
>
> On my FreeBSD 5.0-20000528-CURRENT box, psql -l (from pg_ctl)
> sucks down a big 28% cpu.
>
> Here is the relevant section of the startup script:
>
> start)
> [ -d /usr/local/pgsql/lib ] && /sbin/ldconfig -m /usr/local/pgsql/lib
> [ -x /usr/local/pgsql/bin/pg_ctl ] && {
> su -l pgsql -c \
> 'exec /usr/local/pgsql/bin/pg_ctl -w start > /usr/local/pgsql/errlog
> 2>&1' &
> echo -n ' pgsql'
> }
> ;;
>
> Postgres will start, but I still have that psql -l process cycling
> waiting for a password...
> errlog shows "DEBUG: Data Base System is in production state..."
>
> Ah hah, I think I founnd the source of this and the file descriptor
> problem (for those of you who are familiar with it):

psql tries to read a password from stdin that is not available at boot
time. In simple_prompt in common.c:

do
{
fgets(buf, 512, stdin);
} while (buf[strlen(buf) - 1] != '\n');

Here the return value of fgets() should be checked if fgtes() returns
EOF or not. Otherewise above goes into an infinite loop. Even this
gets fixed, psql would return a fail status and that would be not
suitable for current pg_ctl implementation.

Probably we really need here is a kind of ping tool for PostgreSQL,
instead of using psql.

You could directory invoke postmaster but problem is there is no
reliable way to detect if PostgreSQL up and running other than
trying to make an actual communication with backend...
--
Tatsuo Ishii

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-11-27 03:00:38 Re: Bug? 'psql -l' in pg_ctl?
Previous Message Franck Martin 2000-11-26 23:06:21 RE: [HACKERS] Indexing for geographic objects?