Subject: | Storage::DBI::ODBC cause DBI->connect() to be called twice |
DBIx::Class::Storage::DBI::ODBC causes DBI->connect() to be called
twice each time you connect to the schema. This causes problems when
using MS Access since locks on the database are not released correctly,
even when the perl process is finished.
The problem seems to that DBIx::Class::Storage::DBI::ODBC _rebless()
calls $self->dbh() which causes the second DBI->connect() call.
Replacing $self->dbh() with $self->_dbh in _rebless() fixes the problem.
It seems that is will also be possible to fix this be setting $self-
Show quoted text
>_conn_pid and $self->_conn_tid before the call to _rebless(), but I
have not tried that approach.
I have attached two files with trace information. It contains both the
DBI trace and a call trace for DBIx::Class::Storage::DBI. before.txt
contains the trace with $self->dbh() in _rebless(). after.txt contains
the trace with $self->_dbh() in _rebless()
Subject: | after.txt |
#Trace from DBI.
DBI 1.50-ithread default trace level set to 0x0/1 (pid 2376)
-> DBI->connect(DBI:ODBC:driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb, , ****, HASH(0x215fe50))
-> DBI->install_driver(ODBC) for MSWin32 perl=5.008007 pid=2376 ruid=0 euid=0
install_driver: DBD::ODBC version 1.10 loaded from C:/Perl/site/lib/DBD/ODBC.pm
<- install_driver= DBI::dr=HASH(0x1d83568)
<- default_user(undef undef ...)= ( undef undef ) [2 items] at DBI.pm line 599
<- connect('driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb' undef ...)= DBI::db=HASH(0x21b64b8) at DBI.pm line 617
<- STORE('PrintError' 1)= 1 at DBI.pm line 664
<- STORE('AutoCommit' 1)= 1 at DBI.pm line 664
<- STORE('LongReadLen' 8000)= 1 at DBI.pm line 667
<> FETCH('LongReadLen')= 8000 ('LongReadLen' from cache) at DBI.pm line 667
<- STORE('Username' undef)= 1 at DBI.pm line 667
<> FETCH('Username')= undef ('Username' from cache) at DBI.pm line 667
<- STORE('LongTruncOk' 1)= 1 at DBI.pm line 667
<- FETCH('LongTruncOk')= 1 at DBI.pm line 667
<- connect= DBI::db=HASH(0x21b64b8)
<- STORE('dbi_connect_closure' CODE(0x21b635c))= 1 at DBI.pm line 683
<- STORE('HandleError' CODE(0x21b69a4))= 1 at DBI.pm line 847
<- STORE('ShowErrorStatement' 1)= 1 at DBI.pm line 848
<- STORE('RaiseError' 1)= 1 at DBI.pm line 849
<- STORE('PrintError' 0)= 1 at DBI.pm line 850
<- FETCH('AutoCommit')= 1 at Grouped.pm line 267
<- FETCH('Driver')= DBI::dr=HASH(0x1d83568) at DBI.pm line 776
<> FETCH('Name')= 'ODBC' ('Name' from cache) at DBI.pm line 776
<- get_info(17)= 'ACCESS' at ODBC.pm line 11
<- DESTROY(DBI::db=HASH(21b6758))= undef
<- disconnect_all= '' at DBI.pm line 692
! <- DESTROY(DBI::dr=HASH(1d83568))= undef during global destruction
#DBIx::Class::Storage::DBI trace created with Devel::TraceCalls
DBIx::Class::Storage::DBI::ensure_connected
DBIx::Class::Storage::DBI::connected
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_populate_dbh
DBIx::Class::Storage::DBI::_dbi_connect_info
DBIx::Class::Storage::DBI::_connect
DBIx::Class::Storage::DBI::unsafe
DBIx::Class::Storage::DBI::weaken
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::on_connect_do
DBIx::Class::Storage::DBI::_conn_pid
Subject: | before.txt |
#Trace from DBI.
DBI 1.50-ithread default trace level set to 0x0/1 (pid 2276)
-> DBI->connect(DBI:ODBC:driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb, , ****, HASH(0x215fe50))
-> DBI->install_driver(ODBC) for MSWin32 perl=5.008007 pid=2276 ruid=0 euid=0
install_driver: DBD::ODBC version 1.10 loaded from C:/Perl/site/lib/DBD/ODBC.pm
<- install_driver= DBI::dr=HASH(0x1d83568)
<- default_user(undef undef ...)= ( undef undef ) [2 items] at DBI.pm line 599
<- connect('driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb' undef ...)= DBI::db=HASH(0x21b64b8) at DBI.pm line 617
<- STORE('PrintError' 1)= 1 at DBI.pm line 664
<- STORE('AutoCommit' 1)= 1 at DBI.pm line 664
<- STORE('LongReadLen' 8000)= 1 at DBI.pm line 667
<> FETCH('LongReadLen')= 8000 ('LongReadLen' from cache) at DBI.pm line 667
<- STORE('Username' undef)= 1 at DBI.pm line 667
<> FETCH('Username')= undef ('Username' from cache) at DBI.pm line 667
<- STORE('LongTruncOk' 1)= 1 at DBI.pm line 667
<- FETCH('LongTruncOk')= 1 at DBI.pm line 667
<- connect= DBI::db=HASH(0x21b64b8)
<- STORE('dbi_connect_closure' CODE(0x21b635c))= 1 at DBI.pm line 683
<- STORE('HandleError' CODE(0x21b69a4))= 1 at DBI.pm line 847
<- STORE('ShowErrorStatement' 1)= 1 at DBI.pm line 848
<- STORE('RaiseError' 1)= 1 at DBI.pm line 849
<- STORE('PrintError' 0)= 1 at DBI.pm line 850
<- FETCH('AutoCommit')= 1 at Grouped.pm line 267
<- FETCH('Driver')= DBI::dr=HASH(0x1d83568) at DBI.pm line 776
<> FETCH('Name')= 'ODBC' ('Name' from cache) at DBI.pm line 776
<- STORE('InactiveDestroy' 1)= 1 at DBI.pm line 723
-> DBI->connect(DBI:ODBC:driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb, , ****, HASH(0x215fe50))
<- default_user(undef undef ...)= ( undef undef ) [2 items] at DBI.pm line 599
<- connect('driver={Microsoft Access Driver (*.mdb)};dbq=C:/Data/Development/Erm3x/Develop/Tests/ESM/empty.mdb' undef ...)= DBI::db=HASH(0x21b68e4) at DBI.pm line 617
<- STORE('PrintError' 1)= 1 at DBI.pm line 664
<- STORE('AutoCommit' 1)= 1 at DBI.pm line 664
<- STORE('LongReadLen' 8000)= 1 at DBI.pm line 667
<> FETCH('LongReadLen')= 8000 ('LongReadLen' from cache) at DBI.pm line 667
<- STORE('Username' undef)= 1 at DBI.pm line 667
<> FETCH('Username')= undef ('Username' from cache) at DBI.pm line 667
<- STORE('LongTruncOk' 1)= 1 at DBI.pm line 667
<- FETCH('LongTruncOk')= 1 at DBI.pm line 667
<- connect= DBI::db=HASH(0x21b68e4)
<- STORE('dbi_connect_closure' CODE(0x21c2d98))= 1 at DBI.pm line 683
<- STORE('HandleError' CODE(0x21c3278))= 1 at DBI.pm line 847
<- STORE('ShowErrorStatement' 1)= 1 at DBI.pm line 848
<- STORE('RaiseError' 1)= 1 at DBI.pm line 849
<- STORE('PrintError' 0)= 1 at DBI.pm line 850
<- FETCH('AutoCommit')= 1 at Grouped.pm line 267
<- DESTROY(DBI::db=HASH(21b6758))= undef at DBI.pm line 748
<- get_info(17)= 'ACCESS' at ODBC.pm line 11
<- DESTROY(DBI::db=HASH(21c30d4))= undef
<- disconnect_all= '' at DBI.pm line 692
! <- DESTROY(DBI::dr=HASH(1d83568))= undef during global destruction
#DBIx::Class::Storage::DBI trace created with Devel::TraceCalls
DBIx::Class::Storage::DBI::ensure_connected
DBIx::Class::Storage::DBI::connected
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_populate_dbh
DBIx::Class::Storage::DBI::_dbi_connect_info
DBIx::Class::Storage::DBI::_connect
DBIx::Class::Storage::DBI::unsafe
DBIx::Class::Storage::DBI::weaken
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::dbh
DBIx::Class::Storage::DBI::ensure_connected
DBIx::Class::Storage::DBI::connected
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_conn_tid
DBIx::Class::Storage::DBI::_verify_pid
DBIx::Class::Storage::DBI::_conn_pid
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_populate_dbh
DBIx::Class::Storage::DBI::_dbi_connect_info
DBIx::Class::Storage::DBI::_connect
DBIx::Class::Storage::DBI::unsafe
DBIx::Class::Storage::DBI::weaken
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::_dbh_autocommit
DBIx::Class::Storage::DBI::on_connect_do
DBIx::Class::Storage::DBI::_conn_pid
DBIx::Class::Storage::DBI::_dbh
DBIx::Class::Storage::DBI::on_connect_do
DBIx::Class::Storage::DBI::_conn_pid