
list at funkreich
Jun 30, 2008, 6:28 AM
Views: 1972
Permalink
|
|
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
|
|
Quoting Perrin Harkins <perrin[at]elem.com>: > On Mon, Jun 30, 2008 at 4:54 AM, Tobias Kremer <list[at]funkreich.de> wrote: > > We never fork and I thought that Apache::DBI takes care of checking if a > > connection went stale by utilizing DBI's/DBD::mysql's ping() method? > It does, but it can't stop you from doing things like putting a > database handle in a global during startup and trying to use it later. Ok, I narrowed it down to the database connection initiated during server startup. As soon as I remove it the errors vanish completely. But I don't understand why this is causing a problem because Apache::DBI is supposed to not cache connections made during server startup - it even correctly issues a warning. Here are some snippets to illustrate what I'm doing: ----------------------------------- ApacheHandler.pm ----------------------------------- use Apache::DBI; { package HTML::Mason::Commands; use vars qw/ $thefoo /; } my $foo = My::Foo->new(); sub handler { $HTML::Mason::Commands::thefoo = $foo; } ----------------------------------- My/Foo.pm ----------------------------------- sub new { my $dbh = My::Database::dbh(); my $result = $dbh->selectall_arrayref( ... ); # create an object of e.g. My::Bar initialized with row data # and store it in $self. $dbh is never stored somewhere! $dbh->disconnect(); } ----------------------------------- My/Database.pm ----------------------------------- use DBI; sub dbh { DBI->connect( ... ) } Any ideas? Thanks a lot! --Tobias
|