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

Поиск
Список
Период
Сортировка
От Tatsuo Ishii
Тема Re: Bug? 'psql -l' in pg_ctl?
Дата
Msg-id 20001127105304J.t-ishii@sra.co.jp
обсуждение исходный текст
Ответ на Bug? 'psql -l' in pg_ctl?  (GH <grasshacker@over-yonder.net>)
Ответы Re: Bug? 'psql -l' in pg_ctl?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: RE: [HACKERS] Indexing for geographic objects?
Следующее
От: selkovjr@mcs.anl.gov
Дата:
Сообщение: Re: [HACKERS] Indexing for geographic objects?