Skip site navigation (1) Skip section navigation (2)

Re: restarting after power outage

From: Jon Lapham <lapham(at)jandr(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: restarting after power outage
Date: 2005-04-27 18:39:31
Message-ID: 426FDC63.2000104@jandr.org (view raw or flat)
Thread:
Lists: pgsql-general
Tom Lane wrote:
> Jon Lapham <lapham(at)jandr(dot)org> writes:
> 
>>After a power outage (and bad UPS combo, or plug pull, or bad RAM, etc) 
>>sometimes (I would guess <10% of the time) postgresql fails to restart 
>>automatically after booting the computer.  Invariably, it is because the 
>>"postmaster.pid" file exists, but maybe this is just a symptom of 
>>something else.  The solution I have been performing is to simply delete 
>>this file, and then restart postgres (service postgresql start).
> 
>>Is this the correct procedure?
> 
> 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)

--- postgresql  2005-02-21 16:33:37.000000000 -0300
+++ postgresql_pidkiller        2005-04-27 15:38:03.000000000 -0300
@@ -178,6 +178,13 @@
         fi

         echo -n "$PSQL_START"
+
+       # If there is a stray postmaster.pid file laying around, remove it
+       if [ -f "${PGDATA}/postmaster.pid" ]
+       then
+               rm ${PGDATA}/postmaster.pid
+       fi
+
         $SU -l postgres -c "$PGENGINE/postmaster -p ${PGPORT} -D 
'${PGDATA}' ${PGOPTS} &" >> $PGLOG 2>&1 < /dev/null
         sleep 2
         pid=`pidof -s $PGENGINE/postmaster`


-- 
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
  Jon Lapham  <lapham(at)jandr(dot)org>                Rio de Janeiro, Brasil
  Personal: http://www.jandr.org/
***-*--*----*-------*------------*--------------------*---------------


In response to

Responses

pgsql-general by date

Next:From: Tom LaneDate: 2005-04-27 18:47:28
Subject: Re: restarting after power outage
Previous:From: John LiuDate: 2005-04-27 18:32:27
Subject: dump and restore a single table containing large objects

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group