"Too many open files in system" error - Mailing list pgsql-admin

From Jonatan Evald Buus
Subject "Too many open files in system" error
Date
Msg-id 113ce31b0908120955w77029099i7ececc053084095a@mail.gmail.com
Whole thread Raw
Responses Re: "Too many open files in system" error  (Emanuel Calvo Franco <postgres.arg@gmail.com>)
Re: "Too many open files in system" error  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-admin
Greetings,
We're seeing numerous "LOG:  out of file descriptors: Too many open files in system; release and retry" entries as well as quite a few "LOG:  could not open temporary statistics file "global/pgstat.tmp": Too many open files in system"
Much more alarming however, we're seeing errors such as:
FATAL:  could not open file "global/pg_database": Too many open files in system
ERROR:  could not open relation 1663/2219053/2601: Too many open files in system

kern.maxfiles is currently set to 12328 and "sysctl -a | grep kern.openfiles" showed over 10.000 open files prior to a reboot.
After the reboot kern.openfiles quickly increased from less than 200 to over 4000 and appears to be ever increasing.
"lsof | grep postgres | wc -l" showed approximately 4400 just after reboot but appears to be increasing at a steady pace (have increased to around 4800 in 30 min)

System is running FreeBSD 7.1 with 2GB RAM and have been running without issues for over 6 months with PostGreSQL 8.3.6.
We upgraded to PostGreSQL 8.3.7 around a month ago, not sure if this is related?
The server is a dedicated file server running PostGreSQL and Subversion. Subversion has very few users so it shouldn't be an issue.

We've tried changing max_files_per_process to 500 from the default 1000 but this doesn't appear to have had any effect.
Other changes from the default configuration include:
max_connections = 256
shared_buffers = 768MB
temp_buffers = 96MB
max_prepared_transactions = 50
work_mem = 48MB
maintenance_work_mem = 192MB
max_stack_depth = 8MB

Is it normal for PostGreSQL to have close to 5000 file handles open while running?
Or is there some other circumstance which could cause file descriptors to leak?

Appreciate any input

Cheers
Jona

pgsql-admin by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: XID wraparound in 8.4
Next
From: Emanuel Calvo Franco
Date:
Subject: Re: "Too many open files in system" error