vendredi 16 janvier 2015

Mojolicious connection to DB occasionally crashes

I run a productive app to manage publications of our research group. The app is written in mojolicious framework in perl. I use sqlite3 as a DB and Hypnotoad as an app server.


My problem is that the connection to the DB occasionally crashes (2 times per week) without giving a reasonable error message. The only thing that helps is restart of the Hypnotoad. Any ideas why this may happen?


Example of an error message:



[Fri Jan 16 08:43:09 2015] [error] Can't call method "execute" on an undefined value at /home/piotr/perl/publiste2/script/../lib/AdminApi/Core.pm line 525.


The code there looks as follows:



my $qry = "SELECT DISTINCT our_type FROM OurType_to_Type WHERE landing=1 ORDER BY our_type ASC";
my $sth = $dbh->prepare( $qry );
$sth->execute(); # this is the line 525


The dbh variable is returned by helper:



DBI->connect('dbi:SQLite:dbname='.$config->{normal_db}, '', '') or die $DBI::errstr .". File is: ".$config->{normal_db};


Full code is available here: http://ift.tt/17OtKIg


Aucun commentaire:

Enregistrer un commentaire