Class::DBI, mod_perl1, multiple databases, and database handles

[prev] [thread] [next] [Date index for 2004/12/15]

From: "toddrw69
Subject: Class::DBI, mod_perl1, multiple databases, and database handles
Date: 19:14 on 15 Dec 2004
sent to cdbi-talk@xxxxxx.xxxxx.xxx and modperl@xxxx.xxxxxx.xxx

I use Class::DBI to connect to several databases from within mod_perl. Occasionally a request will hang and there will be a slew of "attempt to free unreferenced scalar" messages in the error_log. I am assuming this is because of multiple processes connecting to multiple databases at the same time via a single database handle.

I found this thread where Perrin H. shows how to overload db_Main:

http://aspn.activestate.com/ASPN/Mail/Message/modperl/2203391

This shows how to only connect to a single database, so I modified it a bit so the subclass sets its connection info before the call to connect.

Also, I use Class::DBI::mysql to facilitate setting up the object methods for me.

I think that part works properly, but the server will not start. I think what is blowing up is when Class::DBI::mysql goes to load the table info. Here is the error I get:

configuring DB interface at /usr/local/app/Application/Data.pm line 13.
in my db_Main at /usr/local/app/Application/DBI.pm line 9.
Syntax error on line 1230 of /usr/local/app/apache/conf/httpd.conf:
Can't locate object method "fetch_hash" via package "DBI::st" at /usr/lib/perl5/site_perl/5.8.0/Class/DBI/mysql.pm line 65.
Compilation failed in require at /usr/local/app/Application/Data.pm line 26.
BEGIN failed--compilation aborted at /usr/local/app/Application/Data.pm line 26.
Compilation failed in require at /usr/local/app/Application.pm line 15.
BEGIN failed--compilation aborted at /usr/local/app/Application.pm line 15.
Compilation failed in require at (eval 14) line 3.

./apache/bin/apachectl start: httpd could not be started

Here is the inheratance chain:

Class::DBI
 + Class::DBI::mysql
   + Application::DBI
     + Application::Data
       + Application::Data::Table1
       + My::Database1::Table2
       + ...
     + My::Database2
       + My::Database2::Table1
       + My::Database2::Table2
       + ...
     + ...



You can see the definition of Application::DBI at:

http://waveright.homeip.net/~trwww/code/ApplicationDBIpm.txt

The definition of Application::Data is at:

http://waveright.homeip.net/~trwww/code/ApplicationData.txt

and the code for Application::Data::Person, the module that is being used when the fatal error is generated can be seen here:

http://waveright.homeip.net/~trwww/code/ApplicationDataPerson.txt

Thank you for reading,

Todd W.




_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

Class::DBI, mod_perl1, multiple databases, and database handles
"toddrw69 19:14 on 15 Dec 2004

Generated at 11:26 on 21 Dec 2004 by mariachi v0.52