Intermittent Startup Failures

Started by Debra LaVilleover 24 years ago5 messagesgeneral
Jump to latest
#1Debra LaVille
debra.laville@digeo.com

I have users experiencing problems with PostgreSQL failing to start up
consistently when their machines reboot. (The reboot may or may not be a
result of a machine lockup.) No messages have been logged to the
/var/log/messages file other than "startup failed", but executing the
startup script by hand then successfully starts PostgreSQL. I have also seen
the "starup failed" message displayed on reboot, logged to the messages
file, but when I checked, postmaster acually is running and I was able to
start psql. I'm not a script file or Linux guru, but need to get to the
bottom of this problem. Sorry I cannot provide more data, but any
suggestions to help me debug this problem would be appreciated. BTW, I'm
using PostgreSQL 7.1 with Linux 7.0.

#2Ryan Mahoney
ryan@paymentalliance.net
In reply to: Debra LaVille (#1)
Re: Intermittent Startup Failures

There may be some errors in the script that's loads postgres at
startup. Look in the "/etc/rc.d/init/" directory and see if there is an
executable named postgres or something similar. If so, post the source of
this file to the group so we can take a look.

Good Luck!

-Ryan Mahoney

At 10:22 AM 7/18/01 -0700, Debra LaVille wrote:

Show quoted text

I have users experiencing problems with PostgreSQL failing to start up
consistently when their machines reboot. (The reboot may or may not be a
result of a machine lockup.) No messages have been logged to the
/var/log/messages file other than "startup failed", but executing the
startup script by hand then successfully starts PostgreSQL. I have also seen
the "starup failed" message displayed on reboot, logged to the messages
file, but when I checked, postmaster acually is running and I was able to
start psql. I'm not a script file or Linux guru, but need to get to the
bottom of this problem. Sorry I cannot provide more data, but any
suggestions to help me debug this problem would be appreciated. BTW, I'm
using PostgreSQL 7.1 with Linux 7.0.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01

#3Joseph Shraibman
jks@selectacast.net
In reply to: Debra LaVille (#1)
Re: Intermittent Startup Failures

Debra LaVille wrote:

<snip>

suggestions to help me debug this problem would be appreciated. BTW, I'm
using PostgreSQL 7.1 with Linux 7.0.

There is no Linux 7.0. You probably mean redhat 7.0 which shipped with
a broken glibc. Upgrade your glibc rpms and see if that changes anything.

Also make sure the startup script is symlinked in the right directory. You may have in in rc3.d but the machine is starting up in runlevel 5.

--
Joseph Shraibman
jks@selectacast.net
Increase signal to noise ratio. http://www.targabot.com

#4Debra LaVille
debra.laville@digeo.com
In reply to: Joseph Shraibman (#3)
RE: Intermittent Startup Failures

I'm using the script file included with the postgresql distribution:

***********************************************************************

# PGVERSION is:
PGVERSION=7.1.2

# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions

# Get function listing for cross-distribution logic.
#TYPESET=`typeset -f|grep "declare"`

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0

start(){
PSQL_START=$"Starting postgresql service: "

export PGDATA=/var/lib/pgsql/data
if [ ! -d $PGDATA/base ]
then
# Check version of existing PGDATA

# No existing PGDATA! Initdb it.

echo -n $"Initializing database: "
if [ ! -d $PGDATA ]
then
mkdir -p $PGDATA
chown postgres.postgres $PGDATA
fi
# Make sure the locale from the initdb is preserved for
later startups...
[ -f /etc/sysconfig/i18n ] && cp /etc/sysconfig/i18n
$PGDATA/../initdb.i18n
# Just in case no locale was set, use en_US
[ ! -f /etc/sysconfig/i18n ] && echo "LANG=en_US" >
$PGDATA/../initdb.i18n
# Is expanded this early to be used in the command su runs
echo "export LANG LC_ALL LC_CTYPE LC_COLLATE LC_NUMERIC
LC_CTYPE LC_TIME" >> $PGDATA/../initdb.i18n
# Initialize the database
su -l postgres -s /bin/sh -c "/usr/bin/initdb
--pgdata=/var/lib/pgsql/data > /dev/null 2>&1" < /dev/null
[ -f $PGDATA/PG_VERSION ] && echo_success
[ ! -f $PGDATA/PG_VERSION ] && echo_failure
echo
fi

# Check for postmaster already running...
pid=`pidof -s postmaster`
if [ $pid ]
then
echo $"Postmaster already running."
else
#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.* > /dev/null
echo -n "$PSQL_START"
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
/usr/bin/postmaster start > /dev/null 2>&1" < /dev/null
sleep 1
pid=`pidof -s postmaster`
if [ $pid ]
then
echo " [ OK ]"
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
echo " [ FAILED ]"
echo
fi
fi
}

stop(){
echo -n $"Stopping postgresql service: "
# Check for older PGDATA location.
export PGDATA=/var/lib/pgsql/data

su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl stop -D $PGDATA -s -m
fast" > /dev/null 2>&1
ret=$? # This will always be 0, as the return code doesn't
propagate... Fix that some day.
if [ $ret -eq 0 ]; then
echo_success
else
echo_failure
fi
echo
rm -f /var/run/postmaster.pid
rm -f /var/lock/subsys/postgresql
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/postgresql ] && restart || :
}

# This script is slightly unusual in that the name of the daemon
(postmaster)
# is not the same as the name of the subsystem (postgresql)

# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status postmaster
;;
restart)
restart
;;
condrestart)
condrestart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart}"
exit 1
esac

exit 0
****************************************************************************
***

-----Original Message-----
From: Ryan Mahoney [mailto:ryan@paymentalliance.net]
Sent: Wednesday, July 18, 2001 12:43 PM
To: Debra LaVille; pgsql-general@postgresql.org
Subject: Re: Intermittent Startup Failures

There may be some errors in the script that's loads postgres at
startup. Look in the "/etc/rc.d/init/" directory and see if there is an
executable named postgres or something similar. If so, post the source of
this file to the group so we can take a look.

Good Luck!

-Ryan Mahoney

At 10:22 AM 7/18/01 -0700, Debra LaVille wrote:

I have users experiencing problems with PostgreSQL failing to start up
consistently when their machines reboot. (The reboot may or may not be a
result of a machine lockup.) No messages have been logged to the
/var/log/messages file other than "startup failed", but executing the
startup script by hand then successfully starts PostgreSQL. I have also

seen

Show quoted text

the "starup failed" message displayed on reboot, logged to the messages
file, but when I checked, postmaster acually is running and I was able to
start psql. I'm not a script file or Linux guru, but need to get to the
bottom of this problem. Sorry I cannot provide more data, but any
suggestions to help me debug this problem would be appreciated. BTW, I'm
using PostgreSQL 7.1 with Linux 7.0.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.251 / Virus Database: 124 - Release Date: 4/26/01

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Debra LaVille (#4)
Re: RE: Intermittent Startup Failures

Debra LaVille <debra.laville@digeo.com> writes:

I'm using the script file included with the postgresql distribution:

Hmm, is this from an RPM? It's certainly not part of what *I* consider
the Postgres distribution ...

#all systems go -- remove any stale lock files
rm -f /tmp/.s.PGSQL.* > /dev/null
echo -n "$PSQL_START"
su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p
/usr/bin/postmaster start > /dev/null 2>&1" < /dev/null
sleep 1
pid=`pidof -s postmaster`
if [ $pid ]
then
echo " [ OK ]"
touch /var/lock/subsys/postgresql
echo $pid > /var/run/postmaster.pid
echo
else
echo " [ FAILED ]"
echo
fi

Since this thing is sending the postmaster's stderr output to /dev/null,
it's impossible to tell what's going wrong. Change the su line to be
something like

su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -D $PGDATA -p /usr/bin/postmaster start >> /some/handy/logfile 2>&1" < /dev/null

and then let us know what you see in /some/handy/logfile after you get a
failure.

regards, tom lane