14 messages in com.mysql.lists.perlRe: Maintaining State/Cached Connections
FromSent OnAttachments
Jason Allocco06 Jun 2001 08:13 
ed phillips06 Jun 2001 09:34 
Jeremy Zawodny06 Jun 2001 10:05 
Dodger06 Jun 2001 12:30 
Todd Finney06 Jun 2001 16:14 
Dave Rolsky08 Jun 2001 00:11 
Jochen Wiedmann08 Jun 2001 01:21 
Todd Finney08 Jun 2001 07:49 
Jochen Wiedmann08 Jun 2001 08:54 
Todd Finney08 Jun 2001 09:58 
Jochen Wiedmann08 Jun 2001 15:18 
Stas Bekman08 Jun 2001 21:36 
Jochen Wiedmann10 Jun 2001 07:04 
Stas Bekman10 Jun 2001 07:32 
Subject:Re: Maintaining State/Cached Connections
From:Todd Finney (tfin@boygenius.com)
Date:06/08/2001 07:49:09 AM
List:com.mysql.lists.perl

At 03:12 AM 6/8/01, Dave Rolsky wrote:

On Wed, 6 Jun 2001, Dodger wrote:

If I have an active statement handle prepared in a startup file outside the script and available as a package global, will it go dead under mod_perl and Apache::DBI?

Someone else said this would work but I believe they are incorrect. Your startup file (presumably loaded via PerlRequire startup.pl) will be executed in the parent Apache process _before_ forking. Unfortunately, DBI database handles become invalid after a fork.

You presumably mean 'statement handles' there. Doing a connect_on_init via startup.pl is standard operating procedure, and it works just fine. But you know that.

I didn't advise him that the statement handle could be cached at startup. I only provided a pointer to the guide entry for doing something *close* to what he wanted to do.

http://perl.apache.org/guide/performance.html#Eliminating_SQL_Statement_Parsin

Am I reading that incorrectly?

I believe you are also concerned about what happens if MySQL goes down and then back up while your database handle is connected. In that case your statement handles would certainly become invalid (though Apache::DBI would, I think, handle reconnecting the database handle).

Yep.

The fix for this is to install some sort of handler before the request phase that checks the status of the statement handles (via the Active flag, perhaps), and recreates them if necessary.

Yep.

cheers, Todd