Was this patch from June ever considered?  It's still a problem.

On Sun, Jun 19, 2005, Bill Campbell wrote:
>The attached patch for postgresql addresses a long-standing
>problem with postgresql in which it doesn't restart after an
>abnormal termination (e.g. system reboot after power loss).
>
>The problem is caused because the pg_ctl program only checks for
>the existence of the postmaster.pid file, but doesn't check to
>see if that process is still running.
>
>I looked at the source for the pg_ctl program to see if it would
>be easy to fix it to check the running status, but it didn't look
>like it was going to be easy so I just tweaked the rc.postgresql
>to check this, removing the pid and associated Unix sockets
>before running the pg_ctl check.
>
>This patch is against the Release 2.3 package, but I don't think
>it's significantly different for CURRENT.
>
>Bill
>--
>INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
>UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
>FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
>URL: http://www.celestial.com/
>
>``Perhaps, when committing your first federal crime, it would be unwise to
>slap your name and address on it and mail it to 10,000 people.'' --Dogbert

Bill
--
INTERNET:   [EMAIL PROTECTED]  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

The only logical reason to take guns away from responsible people is to
give irresponsible people an edge in the perpetration of their crimes
against us. -- The Idaho Observer, Vol. 1, No. 2 February 1997
--- rc.postgresql.orig  2005-01-18 11:51:53.000000000 -0800
+++ idiff.out   2005-11-11 15:31:10.417308536 -0800
@@ -22,6 +22,7 @@
     postgresql_opts="-h $postgresql_socket_inet -k $postgresql_socket_unix"
     postgresql_opts="$postgresql_opts $postgresql_flags"
     postgresql_log_file="@l_prefix@/var/postgresql/run/postgresql.log"
+    postgresql_pidfile="@l_prefix@/var/postgresql/db/postmaster.pid"
     postgresql_slony1_pidfile="@l_prefix@/var/postgresql/run/slon.pid"
     postgresql_slony1_start () {
         ( . @l_prefix@/etc/postgresql/slony1.conf
@@ -45,8 +46,19 @@
 %status -u @l_rusr@ -o
     postgresql_usable="unknown"
     postgresql_active="no"
-    rcService postgresql enable yes && \
+    rcService postgresql enable yes && {
+        # The pg_ctl file doesn't do smart things about checking
+        # for running processes so this preliminary test will
+        # remove the pid and Unix domain stuff before running
+        # pg_ctl if the postmaster process isn't active.
+        test -s $postgresql_pidfile && {
+            kill -0 `head -1 $postgresql_pidfile` 2>/dev/null || {
+                rm -f $postgresql_pidfile
+                rm -f $postgresql_datadir/../run/.s*
+            }
+        }
         @l_prefix@/bin/pg_ctl status -D $postgresql_datadir >/dev/null && 
postgresql_active="yes"
+    }
     echo "postgresql_enable=\"$postgresql_enable\""
     echo "postgresql_usable=\"$postgresql_usable\""
     echo "postgresql_active=\"$postgresql_active\""

Reply via email to