Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

  (email not shown publicly)
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Friday December 12, 2003
01:55 PM

DBI funkiness

[ #16311 ]

I was having problems with an application that created loads of DBI handles which just sat around sleeping. Enabling MySQL's query log let me trace through what each connection was doing and I tracked it down to a sub that was like this:

sub do_something {
    my $dbh = init_dbh();
    # do something with dbh
    if ($something) {
        # do something else with dbh

The issue was that instead of causing an error, DBI was magically connecting back to the database that we disconnected from when we executed the next query. This handle was then never being disconnected. Is this a bug? The DBI documentation suggests that "The handle is of little use after disconnecting", and that the handle will be disconnected when the handle goes out of scope.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I think your problem is related to the auto_reconnect setting in DBD::mysql, which was changed [] recently so that it doesn't happen by default. Are you using a version of DBD::mysql older than 2.9002?

    Some of my applications were depending on the reconnection, so they started breaking when I upgraded. I'm still trying to figure out how to get the old behavior, since setting auto_reconnect doesn't seem to solve the problem completely.
    • I'm using 2.9002 which according to the ChangeLog turns on auto_reconnect if $ENV{MOD_PERL} is set. Now I know what's up I'll make sure it's turned off as that seems to make more sense.