Thread: How do I get the database connections to close down?

How do I get the database connections to close down?

From
Marcus Claesson
Date:
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



Re: How do I get the database connections to close down?

From
Oliver Elphick
Date:
On Wed, 2003-02-19 at 11:27, Marcus Claesson wrote:
> 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':

> $set -> Disconnect ();

I think that should be

  $set -> disconnect ();

Perl is case sensititive, isn't it?

--
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "And the angel answered and said unto the women, Fear
      ye not; for I know that ye seek Jesus, who was
      crucified. He is not here; for he is risen, as he
      said...Therefore be ye also ready; for in such an hour
      as ye think not the Son of man cometh."
                              Matthew 28:5,6; 24:44


Re: How do I get the database connections to close down?

From
Marcus Claesson
Date:
> > $set -> Disconnect ();
>
> I think that should be
>
>   $set -> disconnect ();
>
> Perl is case sensititive, isn't it?
>

Nope, that didn't change the outcome. It works well with both cases.

/Marcus