Good morning

I've recently been upgrading and rewriting a mod_perl Translation Handler. It's doing nothing too sophisticated, mainly just using a MySQL database to look up details based on an SSL certificate presented by the client.

So, one of the first things I do is to change the old function handler to being an object handler, and to abstract the storage of the client details, and write some nice tests. I ended up with something like this:

# in a startup.pl use Apache::DBI; my %args = ( 'dsn' => 'dbi:mysql:foo', 'user' => 'xx', 'pass' => 'xx'); # note this does a DBI->connect my $dbsource = MyProject::DBSource::MySQL->new(%dbargs); $My::TransHandler = MyProject::Handler->new('source' => dbsource); # in conf PerlTransHandler $My::TransHandler->handle

However, though it worked fine on my dev box, bad stuff started to happen when it went live on production. All was good for a while after restart, then more and more requests would start crawling. Looking at perrin's comment in this thread, it seems I've done a naughty thing in doing a DBI connect in startup.pl. The enlightenment I seek is why I shouldn't do this, and whether this seems a likely explanation for the problems I was seeing when the code went live.

I'll be cheeky, and ask a supplementary question: any tips for integration testing this sort of thing?

With thanks
ViceRaid


In reply to Objects, Object Handlers and mod_perl by ViceRaid

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.