[Catalyst] Shared database handles

Eduardo Anuel eanuel at gmail.com
Mon May 8 02:10:20 CEST 2006

I think that my problem is the single $dbh problem because it's way
too similar to a problem that somebody posted to the list before [1]
and that was solved for CDBI, according to that the problem was that
CDBI made one single connection at the apache startup and that
connection was shared by all the forked processes.
I looked at the Catalyst::Model::DBI module and it seems to be doing
the same thing; it opens one connection when the application is
started and when we do "$dbh = $c->model('DB')->dbh;" to get the
database handle a reference (of this single connection) is given to
us; this in case of a single process is not a problem because several
calls to that reference are managed in a first in first out way, but
when there are several processes who hold that variable there's no way
to take care of the request other than by using semaphores or another
structure that manages concurrency.

I decided not to use the Catalyst::Model::DBI module and openning and
closing the connections whenever I need it and there hasn't been
anymore errors, I know it could get really slow, but that's my
solution by now, maybe later I can figure out a way to use the module.

[1] http://www.gossamer-threads.com/lists/catalyst/users/2334?search_string=mod_perl%20DBI;#2334

Think for yourself...Question Authority

More information about the Catalyst mailing list