Re: mod_perl2 + fork + DBI = Chaos
Tosh Cooey <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Organization | Twelve Hundred Group LLC |
| Message-ID | <[email protected]> |
Just to follow up on this before anyone spends any time caring about it, the seg faults could also be because one of the zombie apache2 processes I've spawned like a Gremlin is answering the request and well... So, if I've done the fork properly and pretend I have apache PIDs 1..10 running, and the child is 11 and it does it's thing and hits CORE::exit(0) should that process then die? Or will I now see apache processes 1..11? What should I be looking for after a clean fork? Tosh Tosh Cooey wrote: > I wish I could do SQL before the fork, but I need to update tables with > results in the forks. > > Just to make things stranger, after I make a fork and things don't > happen the way I expect them, subsequent calls to other programs running > under mod_perl are generating Segmentation Faults. This could be due to > the fact that the server is running in Europe and the SQL server in > North America. I would really love to hear that this can cause > segmentation faults because otherwise I have no idea where they are > coming from and in all my years using this same framework in mp1, mp2 or > just vanilla CGI I have never seen so many segfaults. > > Bah... > > Tosh > > > [email protected] wrote: >> Have you been through these threads already? >> The first one seems quite like what you're doing. >> >> http://mail-archives.apache.org/mod_mbox/perl-modperl/200908.mbox/%[email protected]%3E >> >> http://www.gossamer-threads.com/lists/modperl/modperl/100099 >> >> Is the time for the SQL inquiry so bad that you can't >> just do the inquiry before the fork-and-exec bit? >> >> Best of Luck, >> cmac >> >> >> On Jan 25, 2010, at 8:07 AM, Tosh Cooey wrote: >> >>> My application-from-hell is doing odd things probably related to the >>> above storms and culminating in a perfect storm. >>> >>> Can anyone point me to resources outlining the best way to use the >>> combination in the subject line? >>> >>> There seems to be many ways of accomplishing specifics but very >>> little generic methodologies which can be adapted. >>> >>> What I'm trying to do is in a nutshell: >>> >>> ########## >>> my $object_with_DBH = new My::DataObject; >>> >>> ... do stuff... >>> >>> if ($pid = fork) { >>> ... parent things ... >>> } elsif (defined $pid) { >>> ... close STDhandles ... >>> >>> my $data = $object_with_DBH->SQL('do SQL stuff with old connection'); >>> >>> exec 'things from $data'; >>> >>> CORE::exit(0); >>> } >>> ########## >>> >>> I've tried Stas' code but that's for MP1, and with $DBI->clone(), and >>> playing with "setsid" from POSIX and on... There seems to be no love >>> between mod_perl2, fork, and DBI. >>> >>> On a side, but possibly related note, my browser is sending a POST >>> request which results in the FORK above and the parent then sends a >>> 302 redirect with some status variables. This works fine, except >>> between the POST and the 302 GET is another POST to the same URI >>> which results in a 500 error, here's the log: >>> >>> "POST /tosh/mailfile.pl HTTP/1.1" 302 282 >>> >>> "POST /tosh/mailfile.pl HTTP/1.1" 500 424 >>> >>> "GET /tosh/index.pl?message=Notice%20sent HTTP/1.1" 200 4309 >>> >>> The browser only seems to see the middle one, the 500. I'm certain >>> this is related to my poor forking above but I have no idea why. Are >>> there any tools for Firefox that will let me track every connection >>> it's making and why? >>> >>> Thanks again for any help with my Frankenstein monster... >>> >>> Tosh >>> >>> -- >>> McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/ >> >> > -- McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/