Re: Warning: Don't delete those /tmp/.PGSQL.* files - Mailing list pgsql-general

From GH
Subject Re: Warning: Don't delete those /tmp/.PGSQL.* files
Date
Msg-id 20001125185932.A39544@over-yonder.net
Whole thread Raw
In response to Re: Warning: Don't delete those /tmp/.PGSQL.* files  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Warning: Don't delete those /tmp/.PGSQL.* files  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Sat, Nov 25, 2000 at 06:40:12PM -0500, some SMTP stream spewed forth:
> GH <grasshacker@over-yonder.net> writes:
> > FATAL 1:  ReleaseLruFile: No open files available to be closed
> > ............................................................pg_ctl:
> > postmaster does not start up
>
> > After that, all postgres processes die and the cycle begins again on
> > subsequent attempts to start postgres.
> > At one point I would receive some "Too many open files" (or similar)
> > error with postgres holding more than 750 file descriptors -- almost
> > entirely consisting of socket streams.
> > What is the significance of "ReleaseLruFile" and how can I repair this?
>
> > This is using FreeBSD 4.1-RELEASE and Postgres 7.0.2.
>
> 7.0.3 will probably help --- the message is coming out of some
> inappropriate error recovery code that we fixed in 7.0.3.
>
> The underlying problem, however, is that you are running out of kernel
> file table slots (ENFILE or EMFILE error return from open()).  Not
> enough info here to tell why that's happening.

Well, through some research of my own I have discovered that the file
issue is somehow related to our startup script:
/usr/local/etc/rc.d/pgsql.sh.
I am not sure how familiar you are with FreeBSD's startup process, but
it will suffice to say that this script expects one of three arguments:
start, stop, or status -- apparently corresponding to the options of
pg_ctl.

When I start the postgres server manually, it runs relatively fine.
i.e.
# su -l pgsql /usr/local/pgsql/bin/pg_ctl -w start > /usr/local/pgsql/errlog 2>&1 &

Here is pgsql.sh:

#!/bin/sh

# $FreeBSD: ports/databases/postgresql7/files/pgsql.sh.tmpl,v 1.8
2000/05/25 09:35:25 andreas Exp $
#
# For postmaster startup options, edit $PGDATA/postmaster.opts.default
# Preinstalled options are -i -o "-F"

case $1 in
start)
    [ -d /usr/local/pgsql/lib ] && /sbin/ldconfig -m /usr/local/pgsql/lib
# Clean up by Matt
# This is a really bad idea, unless we are absolutely certain that there
# are no postgres processes running or that we feel like restoring
# from a recent backup. ;-) gh
    rm -f /tmp/.s.PGSQL*
    [ -x /usr/local/pgsql/bin/pg_ctl ] && {
        su -l pgsql  \
            /usr/local/pgsql/bin/pg_ctl -w start >
/usr/local/pgsql/errlog 2>&1 &
#           /usr/local/pgsql/bin/pg_ctl -w start -o "-B 64 -N 32" start >
/usr/local/pgsql/errlog 2>&1 &
        echo -n ' pgsql'
    }
    ;;

stop)
    [ -x /usr/local/pgsql/bin/pg_ctl ] && {
        su -l pgsql -c 'exec /usr/local/pgsql/bin/pg_ctl -w -m fast stop'
    }
    ;;

status)
    [ -x /usr/local/pgsql/bin/pg_ctl ] && {
        su -l pgsql -c 'exec /usr/local/pgsql/bin/pg_ctl status'
    }
    ;;

*)
    echo "usage: `basename $0` {start|stop|status}" >&2
    exit 64
    ;;
esac

EOF

running this script with "start" causes the postgres server to start,
run out of files, and then shutdown. Postgres is useable until it runs
out of files and shuts down.


Thanks.

gh

>
>             regards, tom lane

pgsql-general by date:

Previous
From: "rob"
Date:
Subject: Integrity Relationships
Next
From: Jeff MacDonald
Date:
Subject: Re: PostgreSQL as windows 2000 Service