How to avoid IDLE database processes ?

Rich Lafferty rich@horde.org
Fri, 23 Feb 2001 17:18:14 -0500


On Fri, Feb 23, 2001 at 07:02:20PM -0300, Alexander E. Belck (alexb@iol.psi.br) wrote:
> I need help and didn't know where to ask.

The FAQ tells you where to ask; it also tells you that the address to
which you sent this message is for contributions to the FAQ, not help
with Horde. That said, I didn't notice you'd sent it to the FAQ
address before composing this, so I may as well send it on. I've Cc'd
the IMP mailing list; please subscribe to that and continue the
discussion there. See <http://www.horde.org/mail/> for details.
 
> I installed Horde-1.2.3 and IMP-2.2.3 with the databese set to Postgres and
> PHP-4.0.3. All seams to work well untill I started to use it 'in production'
> where I soon get all postgresd connections used and a lote of idle
> (unreused) postgres processes to horde database.
> 
> I search the FAQ, where I found a lot of discussions aboute PERSISTENT
> CONECTINS, but non says how to 'kill/timeout' the idle processes or if I
> could NOT use PERSISTENT CONECTIONS eaven with a loss of performance, but
> geting a stable service.

(Say, you don't know Robert McElwaine, do you?)

I'm not sure what "a lot" of connections is. You might wish to move to
IMP 2.2.4; somewhere between 2.2.2 and 2.2.4 we stopped using
persistent connections with Postgres, because they are unreliable in
PHP (in that they don't necessarily get reused). If you can't upgrade
to 2.2.4, then find all occurrences of "pg_pconnect" and replace them
with "pg_connect".
 
> I notice the as the only user of HORDE/IMP I got 2 processes started only by
> pointing my browser to the login. After loggin-in I have already 5
> processes, and after I open a message a allready have 8 processes of
> postgress in IDLE state.

Erm, everything involved will be expecting more than one user, with
the possible exception of your IMAP server, unless you explicitly tell
it otherwise. Apache spawns ten children by default, as does postgres,
IIRC, and so forth. 

> If the intention is to re-use existing conections to speed the access, why a
> single user that is still conected and (I supposed) in the same session and
> serviced by the same Apache process gets so many postgress processes that
> stay alive eaven if he disconects (and for a so long time that it appears
> forever) ?

You disconnect the moment you see something in your browser. THen, you
click on a link, and you connect again, and then immediately
disconnect. A "session" or a "login" is not the same as an HTTP
connection, since HTTP is stateless.

> Please if somebody knows how to setup HORDE with POSTGRES in a way that I
> could use it for a few simultaneos users (+-30) without hanging after a
> while saing that there are no avaiable connections to postgres

Er, this is a different problem entirely (or at least it will be if it
continues after you move to 2.2.4). You tell Postgres how many
connections to allow when you start it; if it's giving that error, you
need to tell it to allow more. Its default is tiny.

  -Rich


-- 
------------------------------ Rich Lafferty ---------------------------
 Sysadmin/Programmer, Instructional and Information Technology Services
   Concordia University, Montreal, QC                 (514) 848-7625
------------------------- rich@alcor.concordia.ca ----------------------