Hi folks --

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.

If I run the query thru Ima::DBI via a command line  perl -M -e, I get the correct answer. If I run the query through a sql tool, I get the correct answer. If I run the query through mason and ima::dbi, I get the incorrect answer. If I restart apache, I then get the correct answer. (A clue, I think.)

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:

Sql::Stash->set_sql('last_downloadevent', q(select max (ymdhms) from r +ktrack.downloadevent),'RKG',0);
which I display in Mason like this
... <% $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>
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.

So I figure something is getting cached, so foe debugging I opted to mangle to query temporarily to ensure it changes on each call:

Sql::Stash->set_sql('last_downloadevent', q(select concat(max(ymdhms) +,'-', now()) from rktrack.downloadevent where ?>0),'RKG',0);
Note how I've appended the time to field to ensure it changes.

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

select max(ymdhms) from rktrack.downloadevent
from the database query tool, I get the correct (the fresh) downloadevent. And if I run the Ima::DBI query from the command line,
perl -MSql::Stash -e "my $ss=Sql::Stash->new; my $sth=$ss->sql_last_do +wnloadevent; $sth->execute; print $sth->fetch"
I get the correct (the fresh) downloadevent.

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?

rkg


In reply to "stale data": mysql, ima-dbi, modperl, mason by rkg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.