Обсуждение: Question on start server using PG_CTL

Поиск
Список
Период
Сортировка

Question on start server using PG_CTL

От
"Mark Steben"
Дата:
Hi folks, were running Postgres 8.2.5 and Linux Redhat.

I run a cron script to start our server using pg_ctl after I copy the data
cluster over from a replicated server.
To test the start success / failure I test for the presence of
postmaster.pid in the cluster.
This weekend, the server started successfully but cron logic went down the
path that postmaster.pid didn't exist.

Do I need to perform another test,
   Or
Is it possible that, during startup, postmaster.pid takes a second or two to
be created and hadn't been created yet when the test was run?
(Test run immediately after start command - perhaps I need to sleep for 5
seconds before the test).
Thanks for your time,

Mark Steben│Database Administrator
@utoRevenueR-"Join the Revenue-tion"
95 Ashley Ave., West Springfield, Ma
413-243-4800 x1512 (Phone) │ 413.732-1824 (Fax)
@utoRevenue is a registered trademark and a division of Dominion Enterprises




Re: Question on start server using PG_CTL

От
Tom Lane
Дата:
"Mark Steben" <msteben@autorevenue.com> writes:
> Is it possible that, during startup, postmaster.pid takes a second or two to
> be created and hadn't been created yet when the test was run?

It's not instantaneous, for sure.  For one thing, the kernel could be
scheduling the postmaster at lower priority than the continued execution
of your startup script.  If you don't have any sleep at all in there
then the risk of failure would be quite high, even assuming the
postmaster would create the pidfile instantaneously once it gets to run.
And there are other things it has to do first, like read the config file
so it knows where the data directory is ...

Since you say you're using pg_ctl, why don't you use its -w option and
not let the script proceed until you know the postmaster is up?

            regards, tom lane