How do I get the database connections to close down? - Mailing list pgsql-general

From Marcus Claesson
Subject How do I get the database connections to close down?
Date
Msg-id Pine.OSF.3.96.1030219111111.29876A-100000@chah.ucc.ie
Whole thread Raw
Responses Re: How do I get the database connections to close down?  (Oliver Elphick <olly@lfix.co.uk>)
List pgsql-general
Hello all,

I really hope anyone out there can help me with this problem!

I'm using Perl dbi:Pg (as well as DBIx::Recordet) in a CGI script where
the users connect to my database through the web. The problem is that the
database connections won't close down and I end up with an increasing
number of these when 'ps-ef|grep postgres':

postgres 22906 695 0 13:40 ? 00:00:00 postgres: apache testdb [local]
postgres 22913 695 0 13:41 ? 00:00:00 postgres: apache testdb [local]
postgres 22926 695 0 13:47 ? 00:00:00 postgres: apache testdb [local]
postgres 22933 695 0 13:59 ? 00:00:00 postgres: apache testdb [local]

After a while they exceed the default number of connections(32) and I get
a Software error message.

This is parts of the script I'm using:
...
$db = DBIx::Database->new('!DataSource' => 'dbi:Pg:dbname=testdb',
                          '!Username' => 'apache',
                          '!KeepOpen' => 1}) ;
...
*set = DBIx::Recordset->Search('!DataSource' => $db,
                               '!Table' => $table,
                               '!Fields' => $joined_col,
                               '$where' => $query);
...
$set -> Disconnect ();

Although this doesn't close any connection and they accumulate in a way I
don't want them to. If I set '!KeepOpen' to 0 I can't run the script since
$db isn't recognized later on.

Using Postgresql v7.2 and Perl 5.8.0.

Really gratefull for any help!

Regards,
Marcus



pgsql-general by date:

Previous
From: "Nigel J. Andrews"
Date:
Subject: Re:
Next
From: "Mark Cave-Ayland"
Date:
Subject: Re: 7.3.1 takes long time to vacuum table?