Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

mod_perl - ghost values

by rpike (Scribe)
on Aug 19, 2014 at 15:52 UTC ( [id://1097992]=perlquestion: print w/replies, xml ) Need Help??

rpike has asked for the wisdom of the Perl Monks concerning the following question:

I'm currently running a cgi Perl application that has worked fine on IIS. We moved the application over to a Linux server and set up mod_perl on it. On the Linux server we're getting some strange results. When we click on a link for mugs (let's say for simplicity sake) we get 5 mugs. If we go to a page for shirts we get 12 t-shirts show up. If we go back to the mugs page it may show the 5 mugs but if you do a refresh (one, twice, or a few times) we'll end up getting 5 mugs displayed along with 3-6 t-shirts from the old link. What could possibly cause values like this to stick around but still get the correct items as well? I'm hoping some suggestions can be thrown out without having to post the lengthy code. Any help would be appreciated.

Replies are listed 'Best First'.
Re: mod_perl - ghost values
by Corion (Patriarch) on Aug 19, 2014 at 16:01 UTC

    mod_perl keeps old values around between page invocations because it runs everything in one (or more) Apache processes. You can easily see if the problem becomes more treatable by launching Apache in single process mode:

    httpd -X

    Then, you should find that all visitors share the same shopping cart instead of wildly changing carts.

    The most likely problem is failing to initialize global variables when you begin processing a page.

    I recommend to move to all-lexical variables.

      Thanks for the post Corion. All variables in the script are declared with 'my'. There were some variables that were declared as 'our' but have since changed to 'my'. I'm using my $q = new CGI() and using CGI::Session as well if that helps any. There are some additional modules as well but all variables inside them are also declared with 'my' except the 'our @ISA = qw(Exporter);' line.

        So, does running Apache in single process mode change anything?

        Also note that "single process" should also mean single-threaded.

Re: mod_perl - ghost values
by Anonymous Monk on Aug 19, 2014 at 22:07 UTC
Re: mod_perl - ghost values
by sundialsvc4 (Abbot) on Aug 19, 2014 at 19:01 UTC

    “Stale data in a cache, load-balancer, proxy server, etc. etc.” immediately comes to mind.   Especially since it seems to happen when you press Refresh, especially several times in a row.   If the URL that is being accessed is flagged somewhere as being “cacheable,” and if the content of the URL-string is not sufficiently distinct, some cache somewhere along the food-chain could decide that the Perl server doesn’t need to be contacted at all.   It will serve-up old data that is unfortunately stale.   Yet it does consist, if you notice, of things that you retrieved recently.

    It is quite possible that “mod_perl” is actually a red-herring in this situation.   The data is not necessarily being cached by Perl or by Apache.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1097992]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-19 20:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found