Re: Database server restarting

From: "shoaib" <shoaibm(at)vmoksha(dot)com>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'Nigel J(dot) Andrews'" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: "'Martijn van Oosterhout'" <kleptog(at)svana(dot)org>, <gearond(at)cvc(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Database server restarting
Date: 2003-05-07 02:00:04
Message-ID: 001c01c3143c$60ffb570$131f020a@vmoksha
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am not using any restart script ( may be I understood u wrongly)
But I am starting postgres at the time of system boot up and this is the
script for that

#! /bin/sh
#
# Startup script to run Postgresql
#
#

start()
{
if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/sbin" ; then
PATH=/sbin:$PATH
fi

if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q "/usr/sbin" ;
then
PATH=/usr/sbin:$PATH
fi

if [ `id -u` = 0 ] && ! echo $PATH | /bin/grep -q
"/usr/local/sbin" ; then
PATH=/usr/local/sbin:$PATH
fi

if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then
PATH="$PATH:/usr/X11R6/bin"
fi

PATH=$PATH:.:/usr/local/jdk/bin:/usr/local/pgsql/bin

#FOR NON-RAID
#PGDATA=/usr/local/pgsql/data
#FOR RAID
PGDATA=/data/pgsql/data

export PATH PGDATA

su -l postgres -s /bin/sh -c "/usr/local/pgsql/bin/pg_ctl start
-D $PGDATA -o '-i' -s -l $PGDATA/simspgsql.log &"

sleep 1
if [ -f $PGDATA/postmaster.pid ]
then
echo "PostgreSQL started"
else
echo "PostgreSQL not started"
fi
}

stop()
{
su -l postgres -s /bin/sh -c "/usr/local/pgsql/bin/pg_ctl stop
-D $PGDATA -s -m fast"
sleep 1
if [ -f $PGDATA/postmaster.pid ]
then
echo "PostgreSQL not stopped"
else
echo "PostgreSQL is currently stopped"
fi
}

restart()
{
stop
start
}

status()
{
su -l postgres -s /bin/sh -c "/usr/local/pgsql/bin/pg_ctl status
-D $PGDATA"
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
esac

Let m know if there is any problem in it.

Regards,
Shoaib

-----Original Message-----
From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Tuesday, May 06, 2003 10:22 PM
To: Nigel J. Andrews
Cc: shoaib; 'Martijn van Oosterhout'; gearond(at)cvc(dot)net;
pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Database server restarting

"Nigel J. Andrews" <nandrews(at)investsystems(dot)co(dot)uk> writes:
>> But is there any particular reason for database to do such kind of
>> behavior.
>> DEBUG: pq_recvbuf: unexpected EOF on client connection
>> DEBUG: pq_recvbuf: unexpected EOF on client connection
>> DEBUG: pq_recvbuf: unexpected EOF on client connection
>> DEBUG: pq_recvbuf: unexpected EOF on client connection
>> DEBUG: database system was interrupted at 2003-05-03 04:17:19 SGT
>> DEBUG: checkpoint record is at 3/85EA18B0

> You've got high system load, inability for processes to claim more
memory and
> errors about programs exiting at unexpected times.

What strikes me about the above trace is that we see "database system
was interrupted" without any prior failure. That says to me that
something killed the postmaster itself --- if a database child process
died, the postmaster would have logged the fact.

That leaves me with two questions: what killed the postmaster, and what
restarted it?

If Nigel's guess is right that the system is under heavy memory
pressure, and this is a Linux box, then the kernel itself might have
kill -9'd the postmaster to try to get out of a memory shortage.
I can't think of very many other theories (though I do recall at
least one self-inflicted problem, from someone whose "maintenance
script" kill -9'd the postmaster for random reasons...)

I'd also like to know whether the system is configured to auto-restart
the postmaster, and if so how, and does it do any mucking about (like
removing lockfiles) while it's doing so?

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-05-07 02:55:27 Re: Perl DBI::Pg - Stop button
Previous Message Doug McNaught 2003-05-06 23:52:28 Re: How to hook up Access to Postgres?