Re: postmaster didnt start after power failure. - Mailing list pgsql-novice

From Tom Lane
Subject Re: postmaster didnt start after power failure.
Date
Msg-id 7045.1053528232@sss.pgh.pa.us
Whole thread Raw
In response to postmaster didnt start after power failure.  (HK <harikrishnan@midascomm.com>)
List pgsql-novice
HK <harikrishnan@midascomm.com> writes:
> I am using RH 7.2 and postgres 7.1.3.
> Can anyone clarify  on why the pid file is not removed on next bootup?

Recent versions of PG (I don't think 7.1.3 qualifies as recent anymore)
will usually restart successfully even if the postmaster.pid file is
still present.  The postmaster is bright enough to check whether the PID
mentioned in the file actually belongs to a live process (and is not its
own PID, so we handle the case where successive reboots assign the same
PID to the postmaster).

However, there is a corner case if the reboot process isn't 100%
repeatable --- it may be that the current postmaster got assigned a PID
a few counts different from what it had in the last boot cycle, and the
PID it had last time is now assigned to another daemon process created
at boot time.  In that case the postmaster will think the lock file
represents an already-live postmaster and will refuse to start.

The same scenario exists for other standard daemons such as sendmail.
Usually, there is some early-in-boot script responsible for removing
leftover pid files to ensure those daemons will restart.  You might want
to find that script and add PG's pidfiles (there are two) to its list of
things to zap.

I do *not* recommend putting this action into PG's own start script,
since that script is often re-used after initial system boot to
start/stop the postmaster by hand.  If you put an "rm pidfile" in it,
you just blew away your protection against mistakenly starting two
postmasters manually.  Which is a really, really bad mistake...

            regards, tom lane

pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: parse error when executing a simple plpgsql function
Next
From: Joe Conway
Date:
Subject: Re: connect by [prior]