Re: automatic restart on reboot - Mailing list pgsql-general

From Tom Lane
Subject Re: automatic restart on reboot
Date
Msg-id 17236.1042421943@sss.pgh.pa.us
Whole thread Raw
In response to Re: automatic restart on reboot  (Dan Langille <dan@langille.org>)
List pgsql-general
> On Sun, 12 Jan 2003, Aurangzeb M. Agha wrote:
>> I'm deploying Postgres on a production environment and wanted to know if
>> people could share what steps they've taken to have their DB's come back
>> up on system reboot (either on purpose or accidental).
>>
>> Are there any things to check for?
>>
>> What about postmaster.pid, /tmp/blah..., etc...  Any script examples would
>> be appreciated.

Assuming that you've got things set up to start PG from an init script,
it should usually Just Work.

Once in a while, if your system crashed without shutting down Postgres,
the postmaster will refuse to start because it sees the
$PGDATA/postmaster.pid file and thinks there's already a postmaster
running.  (This can only happen if the PID assigned to the postmaster
before the system crash chances to match a different process that is
alive at the instant the new postmaster tries to start.)  You can defend
against that by forcibly removing $PGDATA/postmaster.pid during boot
before you try to start the postmaster.

HOWEVER: that's only a good idea if you do it in a script that is
guaranteed to run ONLY at system boot.  Don't put it into the start
script for Postgres itself, or you'll have broken the interlock against
starting two postmasters in the same $PGDATA directory.  Which is a Very
Important Safety Feature.  If you do that, the consequences will be far
far worse than just having the postmaster not start automatically after
a reboot :-(

There are other standard system daemons, such as sendmail, that also
need pidfiles removed during boot if you want to be certain that they'll
start reliably.  If you dig around in your boot scripts you will
probably find someplace that handles this.  That's where to add
$PGDATA/postmaster.pid.

            regards, tom lane

pgsql-general by date:

Previous
From: Dan Langille
Date:
Subject: Re: automatic restart on reboot
Next
From: "Daniel Morgan"
Date:
Subject: Re: PostgreSQL on Windows