Re: Cannot Start Postgres After System Boot - Mailing list pgsql-general

From Tom Lane
Subject Re: Cannot Start Postgres After System Boot
Date
Msg-id 11894.1287633057@sss.pgh.pa.us
Whole thread Raw
In response to Re: Cannot Start Postgres After System Boot  (Rich Shepard <rshepard@appl-ecosys.com>)
Responses Re: Cannot Start Postgres After System Boot
Re: Cannot Start Postgres After System Boot
List pgsql-general
Rich Shepard <rshepard@appl-ecosys.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

pgsql-general by date:

Previous
From: Tim Uckun
Date:
Subject: Re: Updates, deletes and inserts are very slow. What can I do make them bearable?
Next
From: Tim Uckun
Date:
Subject: Re: Updates, deletes and inserts are very slow. What can I do make them bearable?