Re: Cannot Start Postgres After System Boot

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Cannot Start Postgres After System Boot
Date: 2010-10-21 03:50:57
Message-ID: 11894.1287633057@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Rich Shepard <rshepard(at)appl-ecosys(dot)com> writes:
> The entire script is attached. It's only 2588 bytes.

Personally, I'd drop all the machinations with checking the pidfile or
removing old socket files. The postmaster is fully capable of doing
those things for itself, and is much less likely to do them mistakenly
than this script is. In particular, I wonder whether the script's
refusal to start if the pidfile already exists accounts for your
report that it fails to auto-restart after a reboot.

IOW, this:

> else # remove old socket, if it exists and no daemon is running.

> if [ ! -f $DATADIR/$PIDFILE ]; then
> rm -f /tmp/.s.PGSQL.5432
> rm -f /tmp/.s.PGSQL.5432.lock
> # pg_ctl start -w -l $LOGFILE -D $DATADIR
> su postgres -c 'postgres -D /var/lib/pgsql/data &'
> exit 0
> else
> echo "PostgreSQL daemon was not properly shut down"
> echo "Please remove stale pid file $DATADIR/$PIDFILE"
> exit 7
> fi

> fi

could be reduced to just:

else
su postgres -c 'postgres -D /var/lib/pgsql/data &'
exit 0
fi

I'd also strongly recommend making that be "su - postgres -c ..."
rather than the way it is now; it's failing to ensure that the
postmaster is started with the postgres account's login settings.

I'm not sure about your comment that manual start attempts fail with
LOG: could not bind IPv4 socket: Address already in use
It's pretty hard to believe that that could occur on a freshly
booted system unless the TCP port was in fact already in use ---
ie, either there *is* a running postmaster, or something else is
using port 5432.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Uckun 2010-10-21 03:52:51 Re: Updates, deletes and inserts are very slow. What can I do make them bearable?
Previous Message Tim Uckun 2010-10-21 03:44:01 Re: Updates, deletes and inserts are very slow. What can I do make them bearable?