[Resending] [rt.cpan.org #35942] Connections remain open even when out of scope

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Resending] [rt.cpan.org #35942] Connections remain open even when out of scope

jothi libitha
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


From Chandigarh to Chennai - find friends all over India. Click here.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Loading...