Thread: postmaster didnt start after power failure.

postmaster didnt start after power failure.

From
HK
Date:
hi all,
    After a power failure in my PC, postmaster didnt start. Manually
starting it by "/etc/init.d/postgresql start" also didnt help. Finally i traced
the problem to be existance of the postmaster.pid file. After i deleted that
file, postmaster started properly. This happened two times.
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?
My system is automated and can run for months together without any manual
interventions. In that case, in an unlikely event of power failure, the system
functioning may become improper.
Can somebody suggest a way out of this, please.

--
regards,
hari
      __
     / /    __  _  _  _  _ __  __         -o)
    / /__  / / / \\// //_// \\ \\/ /         /\\\\  Making things happen
   /____/ /_/ /_/\\/ /___/  /_/\\_\\        _\\_v-



Re: postmaster didnt start after power failure.

From
Tom Lane
Date:
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