[Dbix-class] [Resending in plain text format] [rt.cpan.org #35942] Connections remain open even when out of scope

jothi libitha libithashanmugam at yahoo.com
Fri Jul 4 12:02:24 BST 2008


Hi,
My message shows up in encoded form in mailing list archive page. Hence, resending it.

The bug I filed on this issue was rejected. Details of it can be found here.
http://rt.cpan.org/Public/Bug/Display.html?id=35942

The issue is that connections remain open even when out of scope in the latest version of DBIx. Here is the sample code.

sub connect_to_db {
my $schema = SchemaClass->connect();
}

for (my $i = 0; $i < 10; $i++) {
connect_to_db();
}
print "Press enter to quit\n";
my $key = <STDIN>;

DB
connections should be closed at the end of function call. But, in this
case you can see the connections remaining open till you provide an
input the quit.

I don't have this issue with version 0.07002 of
DBIx-Class. When I tried tracing program executions with both versions
of DBIx-class and compared them, I found a code change in
DBIx/Class/Storage/DBI.pm.

The latest version has one additional statement in sub '_verify_pid' of DBIx/Class/Storage/DBI.pm.

sub _verify_pid {
  my ($self) = @_;

  return if defined $self->_conn_pid && $self->_conn_pid == $$;

  $self->_dbh->{InactiveDestroy} = 1;
  ...

}

From
DBI docs, I understand that if this flag is not set, the dbi handle
will be destroyed when last reference is removed. If it set, then it
means 'treat the handle as not-Active in the DESTROY method' and the
database engine related effects of DESTROYing a handle will be skipped.

Commenting
the statement solves the issue I face. But, I am not sure about the
consequences of it. Could someone tell me what is the significance of
having this statement in this file and what would be the correct
solution?

Thanks,
Libitha


      Did you know? You can CHAT without downloading messenger. Go to http://in.messenger.yahoo.com/webmessengerpromo.php/ 




More information about the DBIx-Class mailing list