Restart after poweroutage - Mailing list pgsql-general

From Jon Lapham
Subject Restart after poweroutage
Date
Msg-id 451683E4.6000707@jandr.org
Whole thread Raw
Responses Re: Restart after poweroutage  (Richard Broersma Jr <rabroersma@yahoo.com>)
Re: Restart after poweroutage  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Restart after poweroutage  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I recently had another electrical power outage that left my machine
unable to restart postgresql.  I had previously reported this a while ago:

http://archives.postgresql.org/pgsql-general/2005-04/msg01286.php

Anyway, because I have seen this problem before, I knew exactly what the
solution to the problem was (delete the postmaster.pid file), but for
yucks I decided to imagine I did not know.  What would I need to do to
figure this out.

[root@bilbo ~]# cat /etc/issue
Fedora Core release 5 (Bordeaux)
[root@bilbo ~]# rpm -q postgresql
postgresql-8.1.4-1.FC5.1

Looking in /etc/init.d/postgresql I found that this file exists:
/var/lib/pgsql/pgstartup.log

[root@bilbo ~]# grep PGLOG /etc/init.d/postgresql
PGLOG=/var/lib/pgsql/pgstartup.log

Looking at $PGLOG, I discovered:
FATAL:  pre-existing shared memory block (key 5432001, ID 65536) is
still in use
HINT:  If you're sure there are no old server processes still running,
remove the shared memory block with the command "ipcclean", "ipcrm", or
just delete the file "postmaster.pid".

 From this commentary, to find "postmaster.pid" I ran:
[root@bilbo ~]# find /var | grep postmaster.pid
/var/lib/pgsql/data/postmaster.pid

[root@bilbo ~]# rm /var/lib/pgsql/data/postmaster.pid
[root@bilbo ~]# service postgresql start
Starting postgresql service:                               [  OK  ]

I am a long time pgsql user, and it still took me a while (and some
hunting) to find the solution to this problem.  This may be a real
stumbling block of a new user.  According to commentary on my report
from April 2005, Tom mentions that there was an automated solution to
this issue in v8.0.2:

http://archives.postgresql.org/pgsql-general/2005-04/msg01289.php

I can reproduce this problem in v8.1.4 by these simple steps:

[root@bilbo ~]# service postgresql start
Starting postgresql service:                               [  OK  ]
[root@bilbo ~]# service postgresql stop
Stopping postgresql service:                               [  OK  ]
[root@bilbo ~]# touch /var/lib/pgsql/data/postmaster.pid
[root@bilbo ~]# service postgresql start
Starting postgresql service:                               [FAILED]
[root@bilbo ~]# rm /var/lib/pgsql/data/postmaster.pid
[root@bilbo ~]# service postgresql start
Starting postgresql service:                               [  OK  ]

PS: This email is just a FYI, not a complaint.  Maybe it is just a right
of passage that users of postgresql will just have to learn about this.

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


pgsql-general by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: powerset?
Next
From: Michael Fuhr
Date:
Subject: Re: powerset?