Hi All,
I am having problem with database connection for the session locks dropping
intermittently...
this is what i get in the error log:
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54.
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54.
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54.
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54.
DBD::mysql::st execute failed: Lost connection to MySQL server during query
at /usr/share/perl5/Apache/Session/Lock/MySQL.pm line 54.
this is the apache handler (and the mason handler):
{
my $main_dbh = MyApp::DB->_connect_db(db_name => 'myapp');
sub __admin_mason_handler
{
return HTML::Mason::ApacheHandler->new(
comp_root => [
[ admin =>'/app/admin' ],
[ share => '/app/share' ],
],
data_dir => '/data/admin',
allow_globals => [qw/$e $admin/],
autohandler_name => 'autohandler.htm',
request_class => 'MasonX::Request::WithApacheSession',
session_class => 'Apache::Session::MySQL',
session_use_cookie => 1,
session_cookie_name => 'myapp-admin',
session_handle => $main_dbh,
session_lock_handle => $main_dbh,
);
}
}
sub handler($$)
{
my $class = shift;
my $r = Apache::Request->new(shift);
return __admin_mason_handler()->handle_request($r);
}
explanation: I put __admin_mason_handler in a closure to allow other
applications' mason handler share the database connection $main_dbh.
here is MyApp::DB::_connect method:
sub _connect_db
{
my $class = shift;
my %args = validate(@_, {
db_name => { type => SCALAR, default => 'anonymous' },
});
my $dsn = 'dbi:mysql:host='.$db_host;
$dsn .= ';database='.$args{db_name} if $args{db_name} ne 'anonymous';
my $dbh = DBI->connect_cached($dsn, $db_user, $db_pass, { RaiseError => 1,
PrintError => 1, PrintWarn => 1 }) or die $DBI::errstr;
error(E_GENERIC, $DBI::errstr) unless $dbh;
return $dbh;
}
I use Apache::DBI in startup.pl to have persistent connection.
could anyone help me with this? is this a problem in my code related to my
usage of closure? or is it related to how the Apache::DBI connection works?
thanks for your attention...
---
Badai Aqrandista
Cheepy (?)
_________________________________________________________________
Search for local singles online @ Lavalife - Click here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D21550&_t=21550&_r=endtext&_m=EXT
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Mason-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mason-users