How do I get the database connections to close down?

From: Marcus Claesson <marcus(at)chah(dot)ucc(dot)ie>
To: pgsql-general(at)postgresql(dot)org
Subject: How do I get the database connections to close down?
Date: 2003-02-19 11:27:27
Message-ID: Pine.OSF.3.96.1030219111111.29876A-100000@chah.ucc.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Bartlett 2003-02-19 11:43:53 Re: Table Partitioning in Postgres:
Previous Message Mark Cave-Ayland 2003-02-19 11:06:21 Re: 7.3.1 takes long time to vacuum table?