You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Jonathan <mo...@2xlp.com> on 2005/10/17 02:48:33 UTC

Apache::DBI Question

my webapp is using mysql + apache::dbi to store data

on starting up my webapp, i need to pull some data from mysql that is  
in the parent process (pre fork)

pre fork connections are bad though, so i'm wondering:

a_ do i have 2 db connect strings:
         1. prefork dbh - instantiated prefork , then disconnect
         2. postfork dbh - instantiated postfork

b_ do i have 1 db connection string
         1. standard dbh - instantiate prefork, then disconnect
         2. standard dbh - instantiate postfork

c_ something else

any help will be appreciated

Re: Apache::DBI Question

Posted by Jonathan <mo...@2xlp.com>.
a) perrin, thanks again.
I checked the DBI pod and source, and couldn't elucidate the info  
that i needed.  some of the source is above my skillset still.

b)
> Here is some:
> http://modperlbook.org/html/ch01_02.html
saw that in the print version.  there's a bit in the devel cookbook  
too, but not much in the official docs.

c)
> I'd be happy to offer suggestions and fixes if you start it up.
> - Perrin

I'm going to start an outline tonight on what I think should be  
covered, and take a stab at the answers.
I'll put it on publically writable wiki, and post the url here.   
hopefully some people can set me straight, add what they think should  
be in there, and then add the document to the mod_perl docs.

Re: Apache::DBI Question

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2005-10-17 at 10:27 -0400, Jonathan wrote:
> perrin: great - i couldn't find any documentation on this!

The Apache::DBI source is short and simple, so don't be afraid to read
it if you are wondering about how it handles something.  (Not that you
shouldn't ask questions, but reading the source can be pretty
informative.)  You will get a warning in your error_log about the
connection being opened at startup, but it's harmless.  Just make sure
you close the connection when you're done with it and don't put it in a
global.

> all: can i wishlist some more documentation on the forking process

Here is some:
http://modperlbook.org/html/ch01_02.html

> maybe something like the compression faq, where we go into detail  
> about exactly when where why you do things before/after the fork

The bottom line is that you shouldn't share sockets or filehandles
between forked processes.

> i'd be happy to start on an outline and contribute, but i'm still  
> wary on this issue and don't have much to contribute just yet.

I'd be happy to offer suggestions and fixes if you start it up.

- Perrin


Re: Apache::DBI Question

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Jonathan wrote:
> 
> perrin: great - i couldn't find any documentation on this! thanks a ton.
> 
> all: can i wishlist some more documentation on the forking process
You write it, I'll commit it :)

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


Re: Apache::DBI Question

Posted by Jonathan <mo...@2xlp.com>.
perrin: great - i couldn't find any documentation on this! thanks a ton.

all: can i wishlist some more documentation on the forking process

maybe something like the compression faq, where we go into detail  
about exactly when where why you do things before/after the fork,  
show some more examples, etc.  the current documentation on this is  
sparse.

i'd be happy to start on an outline and contribute, but i'm still  
wary on this issue and don't have much to contribute just yet.  its a  
topic that i see coming up often - both in my own work, and looking  
at other's questions posted on the list.

On Oct 16, 2005, at 11:38 PM, Perrin Harkins wrote:

> Jonathan wrote:
>
>> on starting up my webapp, i need to pull some data from mysql that  
>> is  in the parent process (pre fork)
>> pre fork connections are bad though, so i'm wondering:
>> a_ do i have 2 db connect strings:
>>         1. prefork dbh - instantiated prefork , then disconnect
>>         2. postfork dbh - instantiated postfork
>> b_ do i have 1 db connection string
>>         1. standard dbh - instantiate prefork, then disconnect
>>         2. standard dbh - instantiate postfork
>> c_ something else

Re: Apache::DBI Question

Posted by Perrin Harkins <pe...@elem.com>.
Jonathan wrote:
> on starting up my webapp, i need to pull some data from mysql that is  
> in the parent process (pre fork)
> 
> pre fork connections are bad though, so i'm wondering:
> 
> a_ do i have 2 db connect strings:
>         1. prefork dbh - instantiated prefork , then disconnect
>         2. postfork dbh - instantiated postfork
> 
> b_ do i have 1 db connection string
>         1. standard dbh - instantiate prefork, then disconnect
>         2. standard dbh - instantiate postfork
> 
> c_ something else

You can do b, because Apache::DBI will recognize that you are still in 
startup and not make that connection persistent.

- Perrin