--
Puneet Kishor http://punkish.org
Researcher http://paleodb.org http://macrostrat.org http://carbonmodel.org
Science Fellow http://creativecommons.org
Charter Member http://osgeo.org

On Jul 15, 2011, at 3:48 PM, David Precious <davidp@preshweb.co.uk> wrote:

On Friday 15 July 2011 02:55:55 Mr. Puneet Kishor wrote:
Here is the interesting thing -- if I add the -D switch to the second app
as well, it fails to return the polys and the points. It fails with the
error

{"error":"Warning caught during route execution: DBD::mysql::st
fetchall_arrayref failed: fetch() without execute() at
<path/to>/macrostrat.pm line 79.\n"}

The offending lines are

   71> my $sql = qq{
   72>    ..
   73>
   74>
   75> };
   76>
   77> my $sth = $dbh->prepare($sql);
   78> $sth->execute();
   79> my $res = $sth->fetchall_arrayref({});

The above could be just correlation rather than causal, but it definitely
seems to be a pattern. First, this is bizarre, and why so? And, two...
this is totally bogus... how can execute() not take place above? Perl
doesn't have a habit of jumping over lines, does it?

You haven't actually performed any error checking;

In a later email I did report that --

> Paul Findlay's advice, I launched my offending app with the following invocation
>
>   $DBI_TRACE=2=logs/dbi.log plackup -E production -p 5001 -s Starman -w 10 -a bin/app.pl
>
> And, following is what stood out to me as the potential culprit in the log file
>
>   > Handle is not in asynchronous mode error 2000 recorded: Handle is 
>   > not in asynchronous mode
>   >    !! ERROR: 2000 CLEARED by call to fetch method
>
> (I am shooting in the dark here) I believe Dancer uses a lot of global variables. 
> Would that be connected to this error? On occasion, I am also seeing another 
> mysterious behavior, so mysterious that I feel I am smoking something"

I posted this question on perlmonks as well, and there has been a little discussion, but nothing conclusive yet. [http://www.perlmonks.org/index.pl?node_id=914782]. I am going to try turning on the async feature in DBI and see if that make any difference.


either make sure RaiseError
is enabled on your database handle, or check for errors, e.g.:

 $sth->execute()
     or die "Failed to execute query - " . $dbh->errstr;

As for why the behaviour changed when you selected the production environment,
perhaps it's down to differing settings in enviroments/development.yml and
environments/production.yml ?

The development.yml and production.yml settings are identical in all meaningful ways, as far as I can tell. The only differences are the ones that dancer -a cooks up when creating a bare shell of an app... Different warning levels, warning targets, and that is about it.

The only difference I can see is that with -D switch the app runs in the background, and I get no diagnostic messages. Btw, does Starman (or plackup) support logging error and accept requests like Apache does?



--
David Precious  ("bigpresh")
http://www.preshweb.co.uk/

  "Programming is like sex. One mistake and you have to support
  it for the rest of your life". (Michael Sinz)