[CDBI] Forking and reconnecting to the database

Aaron Trevena aaron.trevena at gmail.com
Wed Mar 8 09:16:02 GMT 2006


On 07/03/06, Perrin Harkins <perrin at elem.com> wrote:
> Nevertheless, you really do need to do it if you want to use Class::DBI
> safely in a forking server.  The code in the above post came from a lot
> of difficult debugging of a forking perl daemon, just like what you're
> describing, and it's significantly trickier to make that work than just
> getting Class::DBI to be mod_perl-safe.  We didn't even notice the
> problem until we had an initial version in production because it's very
> unpredictable.

Yes, I've been wondering why it worked fine with forking off 1 child,
but is a problem when multiple children are forked off... sounds like
you had a nasty time of it.. thanks for sharing the code and
experience.

> We've been using this code long enough now that I'm confident in it.  I
> should update Ima::DBI with it.  However, you will still need to set
> InactiveDestroy in your code.  Meanwhile, the simplest thing you can do
> is to make this modification to your local Ima::DBI.  You could push
> these changes into db_Main in your Class::DBI base class instead, if
> you're familiar with that code.

I'm not very familiar with db_Main, other than  using it to grab a
dbh, but now seems like the right time to learn it better.

On the plus side you have provided a robust and proven solution to my
problem so I can't really complain :)

Cheers,

A.




More information about the ClassDBI mailing list