Re: automatic restart on reboot

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Aurangzeb M(dot) Agha" <aagha(at)bigfoot(dot)com>
Cc: PostgreSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: automatic restart on reboot
Date: 2003-01-13 01:39:03
Message-ID: 17236.1042421943@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Morgan 2003-01-13 03:29:30 Re: PostgreSQL on Windows
Previous Message Dan Langille 2003-01-13 01:03:04 Re: automatic restart on reboot