dbh->ping causes segmentation fault in D::P::Database
The only thing that stopped me from using dancer in production is the problem that it accidently crashes. Today and yesterday I was experimenting to find out the problem. I have found the solution that fixes the problem, but maybe somebody can find better solution. So. How to reproduce the problem. perl, v5.10.1 Dancer v1.2000 Dancer::Plugin::Database v0.11 DBI v1.615 DBD::mysql v4.007 mysql Ver 14.14 Distrib 5.1.41, for debian-linux-gnu (i486) using readline 6.1 Then create simple application ("dancer -a MyDb") in config write db connection info: plugins: Database: driver: 'mysql' database: 'sample' host: 'localhost' username: 'uname' password: 'secret' connection_check_threshold: 1 dbi_params: RaiseError: 1 AutoCommit: 1 on_connect_do: ["SET NAMES 'utf8'", "SET CHARACTER SET 'utf8'" ] In MyDb.pm write something like: my $sth = database->prepare('SELECT count(id) AS c FROM t1'); $sth->execute; $v->{count} = $sth->fetchrow_hashref->{c}; Then start app by "./bin/app.pl", access the page, then restart mysql and try to access the same route again. The app is not responding and in log I get this: [16248] core @0.028376> [hit #8] trying to match `/' against /^\/$/ in /usr/local/share/perl/5.10.1/Dancer/Route.pm l. 74 [16248] core @0.028638> [hit #8] --> got 1 in /usr/local/share/perl/5.10.1/Dancer/Route.pm l. 80 ./start: line 1: 16248 Segmentation fault ./bin/app.pl After investigating I have found that the app is crashed by line "my $result = $dbh->ping" in Dancer/Plugin/Database.pm In the internet I have found the solution http://www.nntp.perl.org/group/perl.dbi.users/2008/07/msg33044.html I've added one line to my config file and it stopped crashing. Here is the fragment of config.yml that works without crahses: dbi_params: mysql_auto_reconnect: 0 RaiseError: 1 AutoCommit: 1
Hi there, On Saturday 04 December 2010 11:20:58 Иван Бессарабов wrote:
The only thing that stopped me from using dancer in production is the problem that it accidently crashes.
[Just to clarify here, for people glancing at list archives "it crashes" is horribly generic; the problem seems to be an odd problem with DBI & DBD::mysql, not with Dancer or D::P::Database] [...]
After investigating I have found that the app is crashed by line "my $result = $dbh->ping" in Dancer/Plugin/Database.pm
In the internet I have found the solution http://www.nntp.perl.org/group/perl.dbi.users/2008/07/msg33044.html
I've added one line to my config file and it stopped crashing. Here is the fragment of config.yml that works without crahses:
dbi_params: mysql_auto_reconnect: 0 RaiseError: 1 AutoCommit: 1
Ah, good stuff. Thank you for taking the effort to both investigate the problem, report it (with all the salient details and how to reproduce it), and even find the solution, too! If I was wearing a hat, it would be off to you. I think to work around this problem, having D::P::Database automatically set mysql_auto_reconnect => 0 upon connecting would be sensible; D::P::Database is taking care of re-establishing database connections when required anyway, so there's no point in it being enabled, especially if it's going to cause problems! I'll look in to this today and get a new version of D::P::Database out including this fix. Thanks again, and thanks also for the connection_check_threshold documentation fix too :) David P -- David Precious <davidp@preshweb.co.uk> (bigpresh) http://blog.preshweb.co.uk/ www.preshweb.co.uk/twitter www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook www.preshweb.co.uk/identica www.lyricsbadger.co.uk "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
[Just to clarify here, for people glancing at list archives "it crashes" is horribly generic; the problem seems to be an odd problem with DBI & DBD::mysql, not with Dancer or D::P::Database]
Yes. You are absolutely right. Sorry not to pointing it in my original mail.
Ah, good stuff. Thank you for taking the effort to both investigate the problem, report it (with all the salient details and how to reproduce it), and even find the solution, too! If I was wearing a hat, it would be off to you.
Thank you! Its a please to hear such words =)
I think to work around this problem, having D::P::Database automatically set mysql_auto_reconnect => 0 upon connecting would be sensible; D::P::Database is taking care of re-establishing database connections when required anyway, so there's no point in it being enabled, especially if it's going to cause problems!
Good. I'm glad that my email caused the correct solution of the problem.
I'll look in to this today and get a new version of D::P::Database out including this fix.
Super! Thank you.
Thanks again, and thanks also for the connection_check_threshold documentation fix too :)
=)
participants (2)
-
David Precious -
Иван Бессарабов