rkg has asked for the wisdom of the Perl Monks concerning the following question:
Yet again I am puzzled and turn to the generous and wise folks here for help. Can anyone offer suggestions?
I am not sure if my problem is perl, mod_perl, mason, mysql, ima::dbi .....
Here's my situation: I seem to be pulling "stale" data from a mysql table. I am running a query select max(ymdhms) from downloadevent.
If I run this though mason and Ima::DBI, I get "stale" data -- that is, rows added since the last apache restart don't get considered.
More details:
The app uses activestate perl 5.8.2, mason 1.25, Apache 1.3.29 (Win32), and mod_perl 1.29_01-dev.
The IMA::DBI statement handle looks like this:
which I display in Mason like thisSql::Stash->set_sql('last_downloadevent', q(select max (ymdhms) from r +ktrack.downloadevent),'RKG',0);
My problem is that the data seems to come back "stale" -- if newer rows (which have ymdhms greater than anything in the table) have been added to rktrack.downloadevent since the last time the Apache restarted, mason / ima::dbi doesn't see them.... <% $last_downloadevent %> ... <%init> use Sql::Stash; my $stash = Sql::Stash->new; my $sth = $stash->sql_last_downloadevent; $sth->execute; my ($last_downloadevent) = $sth->fetch; $sth->finish; ... </%init>
So I figure something is getting cached, so foe debugging I opted to mangle to query temporarily to ensure it changes on each call:
Note how I've appended the time to field to ensure it changes.Sql::Stash->set_sql('last_downloadevent', q(select concat(max(ymdhms) +,'-', now()) from rktrack.downloadevent where ?>0),'RKG',0);
When I display the mason page with this change, mangle field shows the stale downloadevent with the fresh (changing!) time.
This indicates to me that the problem is in the database, perhaps.
And if I run
from the database query tool, I get the correct (the fresh) downloadevent. And if I run the Ima::DBI query from the command line,select max(ymdhms) from rktrack.downloadevent
I get the correct (the fresh) downloadevent.perl -MSql::Stash -e "my $ss=Sql::Stash->new; my $sth=$ss->sql_last_do +wnloadevent; $sth->execute; print $sth->fetch"
I added the "0" to the end of the set_sql to indicate no caching (yes?); I tried adding a dummy placeholder parameter to see if the problem was execute w/o bind values... I tried issuing "commits" from the sql tool; I tried closing the connection that did the insert (just to make sure the insert really hit the database -- it did.) .... no luck. The ima::dbi / mason query doesn't see new inserts into downloadevent until the apache restarts.
I think perhaps I am missing something basic about the database here....
Any suggestions, wise monks?
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: "stale data": mysql, ima-dbi, modperl, mason
by merlyn (Sage) on Dec 26, 2003 at 18:45 UTC | |
by monarch (Priest) on Mar 19, 2006 at 07:58 UTC | |
by merlyn (Sage) on Mar 19, 2006 at 16:56 UTC | |
| |
Some other things you can try:
by Arunbear (Prior) on Dec 26, 2003 at 21:54 UTC | |
Re: "stale data": mysql, ima-dbi, modperl, mason
by rkg (Hermit) on Dec 26, 2003 at 22:59 UTC | |
by perrin (Chancellor) on Dec 27, 2003 at 16:01 UTC | |
Re: "stale data": mysql, ima-dbi, modperl, mason
by CountZero (Bishop) on Dec 26, 2003 at 21:34 UTC | |
by simonm (Vicar) on Dec 27, 2003 at 06:43 UTC |