I use MySQL with the DBI Module for my perl programming database connections.

I see this all over the error_log that apache generates...

[Sun Nov 15 02:59:17 2009] [error] [client 0.0.0.1] DBI::db=HASH(0xc40 +d5a0)->disconnect invalidates 2 active statement handles (either dest +roy statement handles or call finish on them before disconnecting) at + /usr/lib/perl5/site_perl/5.8.8/Apache/Session/Lock/MySQL.pm line 90. [Sun Nov 15 02:59:20 2009] [error] [client 0.0.0.1] DBI::db=HASH(0xb1a +def0)->disconnect invalidates 2 active statement handles (either dest +roy statement handles or call finish on them before disconnecting) at + /usr/lib/perl5/site_perl/5.8.8/Apache/Session/Lock/MySQL.pm line 90.


I always call $sth->finish() on every statement where I do a prepare statement on the database:
$sth = $dbh->prepare(qq{select * from `table`}); $sth->execute(); my $_var = $sth->fetchrow_hashref(); $sth->finish(); #<--- like this here...
however when I just pull a single Item I don't call any kind of finish:
my $_var = $dbh->selectrow_array(qq{select `column` from `table` where + `something` = ?}, undef, "somethingelse"); # Done getting $_var no database connection right, to close right?
at the end of the page loading I call a close to the html page which does this for every page load:
if($sess_ref) { $sess_ref->close(); # If there is a session open, close it } if($dbh) { $dbh->disconnect(); } print end_html();
The close command that the sess_ref uses is here:
sub close { my $self = shift; untie (%{$self}); }

So there is a close to the apache mysql session and a close to the database connection that is using DBI...
So I don't know how there are anything open that is causing a active statement handle to be left open...

Any idea why this happens?
I'd appreciate any feedback.

Thanks,
Rich

In reply to DBI disconnect database errors by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.