You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "rich@cre8tivegroup.com" <ri...@cre8tivegroup.com> on 2001/05/24 23:11:03 UTC

Getting the wrong URL

I'm having a recurring problem that I can't find comment about in the docs, and
I was wondering if anyone might have some insight on this.

I have a web site where *everything* is mod_perl handlers. The problem that I'm
seeing is that I will go to the url http://hostname/foo and I get the content
from http://hostname/bar

This is naturally very distressing me me as the developer, and very confusing
for the user. I suppose it's very likely a problem with my code, rather than
with mod_perl, but if anyone has seen this before and can suggest where I
should be looking.

This seems to be happening when there is a server error of some variety, and
from then on, until a server restart, users are just getting whatever the last
thing was that that Apache child served. I have not been able to completely
verify this, but I am consistently getting the same (wrong) content from a
particular child, so apparently the particular child just keeps giving me
whatever it served the last time.

-- 
The Creative Group Web Application Group
Moving your paper processes to your intranet site



Re: Getting the wrong URL

Posted by "rich@cre8tivegroup.com" <ri...@cre8tivegroup.com>.
On Sat, 26 May 2001 22:41:11 +0800 (SGT), Stas Bekman said:

> On 25 May 2001, rich@cre8tivegroup.com wrote:
>  
>  > Once one handler get  a server error, you'll get the last
>  > succssful content served by that child, repeatedly, forever. Note also that
>  > this not one handler with lots of different behaviors. It's about 20 handlers,
>  > based of some shared base modules, but performing rather different tasks.
>  
>  Can you send us a small handler that reproduces the problem?

No. Unfortunately, it's a pretty complex system, and so far we've been unable
to narrow it down to just one thing. We had a suspicion for a while that it was
related to handlers that were redirecting to other handlers when they were
done, but I've been unable to confirm this yet.
  
>  Have you tried writing the data to the disk instead of/in addition to
>  sending it down to the client? Do you see the data written to the disk
>  (error_log seems to be the best) changing?

What I'm trying to verify now is which URL Apache is even seeing in the
request. However, it does not seem to be logging anything at all. Of course, I
can't reproduce the problem right now. Bah.

-- 
Have trouble remembering things? - http://www.idforgetmyhead.com/



Re: Getting the wrong URL

Posted by Chris Strom <cs...@cos.com>.
"rich@cre8tivegroup.com" <ri...@cre8tivegroup.com> writes:

> OK, I think I have solved this problem, but I would like to run my solution by
> you folks, and see if it makes any sense. What we found, on a more thorough
> code review, was that a number of the handlers were doing a redirect by calling
> send_cgi_header, and then exit()'ing. It seemed to us that the exit would kill
> the Perl interp, and the Apache child would then just keep serving whatever it
> had in its buffer at the time. Does that make any sense? If so, will die() have
> the same results? I started grepping for exit everywhere, and removed it, but
> along the way I saw a number of places that we're calling die.
> 
> I expect that this is just a really stupid newbie problem - I've only been
> doing mod_perl stuff for about 6 months or so. And, in fact, once it occurred
> to me that this might be the problem, of course I found it in the FAQ.

In case you haven't found the guide yet:
http://perl.apache.org/guide/porting.html#Terminating_requests_and_process
http://perl.apache.org/guide/porting.html#die_and_mod_perl

> 
> -- 
> Rich Bowen - Author - Apache Server Unleashed
> http://www.apacheunleashed.com/
> 


Re: Getting the wrong URL

Posted by Doug MacEachern <do...@covalent.net>.
On 1 Jun 2001, rich@cre8tivegroup.com wrote:

> OK, I think I have solved this problem, but I would like to run my solution by
> you folks, and see if it makes any sense. What we found, on a more thorough
> code review, was that a number of the handlers were doing a redirect by calling
> send_cgi_header, and then exit()'ing. It seemed to us that the exit would kill
> the Perl interp, and the Apache child would then just keep serving whatever it
> had in its buffer at the time. Does that make any sense? If so, will die() have
> the same results? I started grepping for exit everywhere, and removed it, but
> along the way I saw a number of places that we're calling die.

i'm missing the original message, but if you can post a small test case,
along with results and expected results, we can look into it.


Re: Getting the wrong URL

Posted by Stas Bekman <st...@stason.org>.
On 1 Jun 2001, rich@cre8tivegroup.com wrote:

> OK, I think I have solved this problem, but I would like to run my solution by
> you folks, and see if it makes any sense. What we found, on a more thorough
> code review, was that a number of the handlers were doing a redirect by calling
> send_cgi_header, and then exit()'ing. It seemed to us that the exit would kill
> the Perl interp, and the Apache child would then just keep serving whatever it
> had in its buffer at the time. Does that make any sense? If so, will die() have
> the same results? I started grepping for exit everywhere, and removed it, but
> along the way I saw a number of places that we're calling die.

I don't think it makes any sense. Also you could look at the handlers
running for each request using Apache::ShowRequest. I think it's mentioned
somewhere in the guide too.

> I expect that this is just a really stupid newbie problem - I've only been
> doing mod_perl stuff for about 6 months or so. And, in fact, once it occurred
> to me that this might be the problem, of course I found it in the FAQ.
>
> --
> Rich Bowen - Author - Apache Server Unleashed
> http://www.apacheunleashed.com/
>
>



_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Re: Getting the wrong URL

Posted by "rich@cre8tivegroup.com" <ri...@cre8tivegroup.com>.
OK, I think I have solved this problem, but I would like to run my solution by
you folks, and see if it makes any sense. What we found, on a more thorough
code review, was that a number of the handlers were doing a redirect by calling
send_cgi_header, and then exit()'ing. It seemed to us that the exit would kill
the Perl interp, and the Apache child would then just keep serving whatever it
had in its buffer at the time. Does that make any sense? If so, will die() have
the same results? I started grepping for exit everywhere, and removed it, but
along the way I saw a number of places that we're calling die.

I expect that this is just a really stupid newbie problem - I've only been
doing mod_perl stuff for about 6 months or so. And, in fact, once it occurred
to me that this might be the problem, of course I found it in the FAQ.

-- 
Rich Bowen - Author - Apache Server Unleashed
http://www.apacheunleashed.com/



Re: Getting the wrong URL

Posted by Stas Bekman <st...@stason.org>.
On 25 May 2001, rich@cre8tivegroup.com wrote:

>
> On Fri, 25 May 2001 23:28:44 +0800 (SGT), Stas Bekman said:
>
> >  > We're not doing anything with Apache::Registry. Everything is with Perl
> >  > handlers. It always seemed to me that the problems described at those locations
> >  > were specific to Apache::Registry. So you're saying that if a Perl handler
> >  > module falls over for some reason, that child will continue serving the last
> >  > content it served, forever? This strikes me as a bad thing.
> >
> >  It's quite possible if you happen to create closures in your "dispatch"
> >  handler for example. It's a bad thing :)
>
> I sort of had the impression that closures were a good way to leak memory, and
> so avoided them.

Good.

> >  > Anyways, all of the possible reasons listed there are not, as far as we can
> >  > tell, going on in our code. Everything is 100% OO, nothing is global or
> >  > exported, and everything uses strict and warnings. Perhaps I'm misunderstanding
> >  > when things actually pass out of scope in a mod_perl environment.
> >  >
> >  > Since almost all of the availble documentation seems to be about using
> >  > Apache::Registry, rather than about writing handlers, it's not always clear
> >  > whether things like this necessarily translate to both.
> >
> >  I'd switch to a single server mode first thing first. Do you see the same
> >  behavior with httpd -X?
>
> Same behavior, yes. Once one handler get  a server error, you'll get the last
> succssful content served by that child, repeatedly, forever. Note also that
> this not one handler with lots of different behaviors. It's about 20 handlers,
> based of some shared base modules, but performing rather different tasks.

Can you send us a small handler that reproduces the problem?

Have you tried writing the data to the disk instead of/in addition to
sending it down to the client? Do you see the data written to the disk
(error_log seems to be the best) changing?

Of course continue the debugging under -X.

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Re: Getting the wrong URL

Posted by "rich@cre8tivegroup.com" <ri...@cre8tivegroup.com>.
On Fri, 25 May 2001 23:28:44 +0800 (SGT), Stas Bekman said:

>  > We're not doing anything with Apache::Registry. Everything is with Perl
>  > handlers. It always seemed to me that the problems described at those locations
>  > were specific to Apache::Registry. So you're saying that if a Perl handler
>  > module falls over for some reason, that child will continue serving the last
>  > content it served, forever? This strikes me as a bad thing.
>  
>  It's quite possible if you happen to create closures in your "dispatch"
>  handler for example. It's a bad thing :)

I sort of had the impression that closures were a good way to leak memory, and
so avoided them.

>  > Anyways, all of the possible reasons listed there are not, as far as we can
>  > tell, going on in our code. Everything is 100% OO, nothing is global or
>  > exported, and everything uses strict and warnings. Perhaps I'm misunderstanding
>  > when things actually pass out of scope in a mod_perl environment.
>  >
>  > Since almost all of the availble documentation seems to be about using
>  > Apache::Registry, rather than about writing handlers, it's not always clear
>  > whether things like this necessarily translate to both.
>  
>  I'd switch to a single server mode first thing first. Do you see the same
>  behavior with httpd -X?

Same behavior, yes. Once one handler get  a server error, you'll get the last
succssful content served by that child, repeatedly, forever. Note also that
this not one handler with lots of different behaviors. It's about 20 handlers,
based of some shared base modules, but performing rather different tasks.

-- 
Rich Bowen - Author - Apache Server Unleashed
http://www.apacheunleashed.com/



Re: Getting the wrong URL

Posted by Stas Bekman <st...@stason.org>.
On 25 May 2001, rich@cre8tivegroup.com wrote:

>
> > On 24 May 2001, rich@cre8tivegroup.com wrote:
> ..
> >  > I have a web site where *everything* is mod_perl handlers. The problem that I'm
> >  > seeing is that I will go to the url http://hostname/foo and I get the content
> >  > from http://hostname/bar
> >  >
> >  > This seems to be happening when there is a server error of some variety, and
> >  > from then on, until a server restart, users are just getting whatever the last
> >  > thing was that that Apache child served. I have not been able to completely
> >  > verify this, but I am consistently getting the same (wrong) content from a
> >  > particular child, so apparently the particular child just keeps giving me
> >  > whatever it served the last time.
>
> >  On Fri, 25 May 2001 10:31:09 +0800 (SGT), Stas Bekman said:
> >  looks like
> >  http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret
> >  http://perl.apache.org/guide/porting.html#Sometimes_it_Works_Sometimes_it
>
> We're not doing anything with Apache::Registry. Everything is with Perl
> handlers. It always seemed to me that the problems described at those locations
> were specific to Apache::Registry. So you're saying that if a Perl handler
> module falls over for some reason, that child will continue serving the last
> content it served, forever? This strikes me as a bad thing.

It's quite possible if you happen to create closures in your "dispatch"
handler for example. It's a bad thing :)

> Anyways, all of the possible reasons listed there are not, as far as we can
> tell, going on in our code. Everything is 100% OO, nothing is global or
> exported, and everything uses strict and warnings. Perhaps I'm misunderstanding
> when things actually pass out of scope in a mod_perl environment.
>
> Since almost all of the availble documentation seems to be about using
> Apache::Registry, rather than about writing handlers, it's not always clear
> whether things like this necessarily translate to both.

I'd switch to a single server mode first thing first. Do you see the same
behavior with httpd -X?


_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/



Re: Getting the wrong URL

Posted by "rich@cre8tivegroup.com" <ri...@cre8tivegroup.com>.
> On 24 May 2001, rich@cre8tivegroup.com wrote:
..
>  > I have a web site where *everything* is mod_perl handlers. The problem that I'm
>  > seeing is that I will go to the url http://hostname/foo and I get the content
>  > from http://hostname/bar
>  >
>  > This seems to be happening when there is a server error of some variety, and
>  > from then on, until a server restart, users are just getting whatever the last
>  > thing was that that Apache child served. I have not been able to completely
>  > verify this, but I am consistently getting the same (wrong) content from a
>  > particular child, so apparently the particular child just keeps giving me
>  > whatever it served the last time.

>  On Fri, 25 May 2001 10:31:09 +0800 (SGT), Stas Bekman said:
>  looks like
>  http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret
>  http://perl.apache.org/guide/porting.html#Sometimes_it_Works_Sometimes_it

We're not doing anything with Apache::Registry. Everything is with Perl
handlers. It always seemed to me that the problems described at those locations
were specific to Apache::Registry. So you're saying that if a Perl handler
module falls over for some reason, that child will continue serving the last
content it served, forever? This strikes me as a bad thing.

Anyways, all of the possible reasons listed there are not, as far as we can
tell, going on in our code. Everything is 100% OO, nothing is global or
exported, and everything uses strict and warnings. Perhaps I'm misunderstanding
when things actually pass out of scope in a mod_perl environment.

Since almost all of the availble documentation seems to be about using
Apache::Registry, rather than about writing handlers, it's not always clear
whether things like this necessarily translate to both.

-- 
Director of Application Development
The Creative Group
http://products.cre8tivegroup.com/



Re: Getting the wrong URL

Posted by Stas Bekman <st...@stason.org>.
On 24 May 2001, rich@cre8tivegroup.com wrote:

> I'm having a recurring problem that I can't find comment about in the docs, and
> I was wondering if anyone might have some insight on this.
>
> I have a web site where *everything* is mod_perl handlers. The problem that I'm
> seeing is that I will go to the url http://hostname/foo and I get the content
> from http://hostname/bar
>
> This is naturally very distressing me me as the developer, and very confusing
> for the user. I suppose it's very likely a problem with my code, rather than
> with mod_perl, but if anyone has seen this before and can suggest where I
> should be looking.
>
> This seems to be happening when there is a server error of some variety, and
> from then on, until a server restart, users are just getting whatever the last
> thing was that that Apache child served. I have not been able to completely
> verify this, but I am consistently getting the same (wrong) content from a
> particular child, so apparently the particular child just keeps giving me
> whatever it served the last time.

looks like
http://perl.apache.org/guide/porting.html#Exposing_Apache_Registry_secret
http://perl.apache.org/guide/porting.html#Sometimes_it_Works_Sometimes_it

_____________________________________________________________________
Stas Bekman              JAm_pH     --   Just Another mod_perl Hacker
http://stason.org/       mod_perl Guide  http://perl.apache.org/guide
mailto:stas@stason.org   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/