|Syntactic Confectionery Delight|
Re: mod_perl, threads, and blank pagesby Codon (Friar)
|on May 08, 2006 at 21:47 UTC||Need Help??|
The system you are describing sounds strangely similar to one we were trying to build: Apache2/mod_perl2 + Perl iThreads, parallel searches to multiple threads, collecting data, returning it back to the user. The differences we had included spawning all threads at ChildInit and putting them into a wait loop, then signalling them when we wanted them to work. They'd go do stuff, put the data in a shared hash, then return to the wait loop.
What we found is that Perl is not thread-safe. Let me repeat that: PERL IS NOT THREAD-SAFE! I say this with emphasis because after several long nights hunting down segfaults in the system, turning on debugging, adding evals to trap errors, banging my head, I came across this in the log:
Common::Logger is our internal logging package. log_stuff is the logging function. It calls CORE::caller(). This blew up. Evidently, the thread boundary is a bit like an event horizon and caller can't cross it without potentially breaking. I saw this message a few more times before we ditched threads entirely.
I strongly encourage you to investigate the possibility of dead threads fouling your app. Then look at alternatives to a threaded model. We moved to a multi-tiered Apache platform. We have an Apache "front-end" that talks to an Apache "back-end" (which in turn can talk to itself; we have layers of parallel and serially parallel processing).
Sr. Software Engineer, DAS Lead