Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found