Re: restarting after power outage - Mailing list pgsql-general

From Philip Hallstrom
Subject Re: restarting after power outage
Date
Msg-id 20050427125304.E58007@wolf.pjkh.com
Whole thread Raw
In response to Re: restarting after power outage  (Doug McNaught <doug@mcnaught.org>)
Responses Re: restarting after power outage  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
>>>> It is.  We have been fooling with the postmaster startup logic to try to
>>>> eliminate this gotcha, but it's only very recently (8.0.2) that I think
>>>> we got it right.
>>
>>> So, then it would be correct to change my init scripts to do the
>>> following:  (if so, this patch can be applied to the 7.4 branch)
>>
>> I would recommend strongly AGAINST that, because what you just did was
>> remove the defense against starting two postmasters concurrently in the
>> same data directory (which would be a disaster of the first magnitude).
>> This is not a problem for bootup of course, but if you ever use this
>> script to start the postmaster by hand, then you are playing with fire.
>
> What I have done is to create a separate init.d script that removes
> the PID file, and arrange for it to run before the PG startup script.
> That way you can use the regular script to stop and start without
> danger, but on a bootup after an unclean shutdown the PID file will
> get removed before PG gets started.  If you're dumb enough to run the
> removal script by hand while PG is running, you deserve what you get.  :)

Or, if your cron supports it, add the following to root's crontab:

@reboot /bin/rm -f /path/to/postgres/pid

Although I like having a separate startup script that runs first to go
around removing this and other things as well...

pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: populating a table via the COPY command using C code.
Next
From: Scott Frankel
Date:
Subject: on insert rule & primary key