Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Reloading Modules Problem [mod_perl2]

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


vbmonymaker at hotmail

Dec 28, 2004, 2:04 PM

Post #1 of 10 (727 views)
Permalink
Reloading Modules Problem [mod_perl2]

I am running Apache 2.0.52 on a solaris 8 box with mod_perl 1.99_12. Over
the weekend I tried to upgrade to the 1.99_19 version of mod_perl. With
mod_perl 1.99_12 all of the requisite modules reloaded properly when their
contents changed. However, with the 1.99_19 version some modules are not
getting reloaded when their contents are changed. All of the effected
modules resided in the directory path '/opt/prod/apache/packages' and did
not have package declarations. So I changed all of the modules so that they
had package declarations per the mod_perl discussion on reloading modules.
When that didn't work I changed the package declarations again so that they
all had 'package Apache::[module];' declarations and moved them all over to
the 'opt/prod/apache/Apache' directory because the modules in that directory
with 'Apache::[module]' package declarations were getting properly reloaded
when changes were made to them.

I then set reload debugging on in the httpd.conf file via the 'PerlSetVar
ReloadDebug On' configuration and saw that the modules that were formerly in
the 'packages' directory but are now in the Apache directory were being
reloaded but unfortunately the changes made to the modules were not being
reflected in the pages put out by Apache. The strange thing is that the
modules that originally resided in the /opt/prod/apache/Apache directory
are being properly reloaded and are having their changes properly reflected
in the webpages put out by the Apache server as opposed to the newly added
modules.

Additionally, with the ReloadDebugger on, all of the modules that have been
changed are showing up as being in the 'Apache/[module]' path and the
'Apache::[module]' namespace and having their contents reloaded. However,
the newly added modules are not having their changes actually show up on the
pages that are served by Apache, whereas the modules that originally were in
the Apache:: namespace are having their changes show up.

With regard to the pertinent details of the my startup.pl file and
httpd.conf file,

use Apache::Reload - is in the startup.pl file and

PerlInitHandler Apache::Reload - is in the httpd.conf file

I have tried various changes to the httpd.conf file such as adding the
following configuration - but all is to no avail

PerlSetVar ReloadAll Off
PerlSetVar ReloadModules "Apache::*"

Only when I switch back to mod_perl 1.99_12 do the modules that have been
newly added to the Apache:: namespace get reloaded when changes are made to
them. BTW, I have run into the same reload problem using mod_perl 1.99_17.
Only version 1.99_12 seems to do the trick

If anyone has any additional suggestions on how I can solve this problem,
your responses would be most appreciated.

Thanks, Vince Moneymaker

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


stas at stason

Dec 28, 2004, 2:31 PM

Post #2 of 10 (683 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Vincent Moneymaker wrote:
> I am running Apache 2.0.52 on a solaris 8 box with mod_perl 1.99_12. Over
> the weekend I tried to upgrade to the 1.99_19 version of mod_perl. With
> mod_perl 1.99_12 all of the requisite modules reloaded properly when their
> contents changed. However, with the 1.99_19 version some modules are not
> getting reloaded when their contents are changed. All of the effected
> modules resided in the directory path '/opt/prod/apache/packages' and did
> not have package declarations. So I changed all of the modules so that they
> had package declarations per the mod_perl discussion on reloading modules.
> When that didn't work I changed the package declarations again so that they
> all had 'package Apache::[module];' declarations and moved them all over to
> the 'opt/prod/apache/Apache' directory because the modules in that directory
> with 'Apache::[module]' package declarations were getting properly reloaded
> when changes were made to them.
>
> I then set reload debugging on in the httpd.conf file via the 'PerlSetVar
> ReloadDebug On' configuration and saw that the modules that were formerly in
> the 'packages' directory but are now in the Apache directory were being
> reloaded but unfortunately the changes made to the modules were not being
> reflected in the pages put out by Apache. The strange thing is that the
> modules that originally resided in the /opt/prod/apache/Apache directory
> are being properly reloaded and are having their changes properly reflected
> in the webpages put out by the Apache server as opposed to the newly added
> modules.
>
> Additionally, with the ReloadDebugger on, all of the modules that have been
> changed are showing up as being in the 'Apache/[module]' path and the
> 'Apache::[module]' namespace and having their contents reloaded. However,
> the newly added modules are not having their changes actually show up on the
> pages that are served by Apache, whereas the modules that originally were in
> the Apache:: namespace are having their changes show up.
>
> With regard to the pertinent details of the my startup.pl file and
> httpd.conf file,
>
> use Apache::Reload - is in the startup.pl file and
>
> PerlInitHandler Apache::Reload - is in the httpd.conf file
>
> I have tried various changes to the httpd.conf file such as adding the
> following configuration - but all is to no avail
>
> PerlSetVar ReloadAll Off
> PerlSetVar ReloadModules "Apache::*"
>
> Only when I switch back to mod_perl 1.99_12 do the modules that have been
> newly added to the Apache:: namespace get reloaded when changes are made to
> them. BTW, I have run into the same reload problem using mod_perl 1.99_17.
> Only version 1.99_12 seems to do the trick
>
> If anyone has any additional suggestions on how I can solve this problem,
> your responses would be most appreciated.

sorry, but I've lost you, Vincent. You say that only 1.99_12 works, but
have you tried other version?. I believe 1.99_16 should work too, please try:
http://search.cpan.org/~stas/mod_perl-1.99_16/

If 1.99_16 works and 1.99_17 doesn't that would probably be the change to
blame:

Added ModPerl::Util::unload_package() to remove a loaded package
as thoroughly as possible by clearing it's stash. [Gozer]

Please confirm that first. Next let's take some specific module, put it in
PerlSetVar ReloadModules enable the debug and show us the relevant bits
from the log, so it'll be easier to visualize the problem.


--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas [at] stason http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


stas at stason

Dec 28, 2004, 2:53 PM

Post #3 of 10 (680 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

[please don't forget to CC the list in your followups]

Vincent Moneymaker wrote:
>>sorry, but I've lost you, Vincent. You say that only 1.99_12 works, but
>
> > have you tried other version?. I believe 1.99_16 should work too, please
> try:
>
>>http://search.cpan.org/~stas/mod_perl-1.99_16/
>>
>>If 1.99_16 works and 1.99_17 doesn't that would probably be the change to
>>blame:
>>
>>Added ModPerl::Util::unload_package() to remove a loaded package
>>as thoroughly as possible by clearing it's stash. [Gozer]
>>
>>Please confirm that first. Next let's take some specific module, put it in
>>PerlSetVar ReloadModules enable the debug and show us the relevant bits
>>from the log, so it'll be easier to visualize the problem.
>>
>
>
> Unfortuantely, I've tried versions 1.99_14, 1.99_15 and 1.99_16 but they all
> have problems with my use of multiple 'PerlSetVar's when used as part of an
> array of VirtualHost's that are created within a <PERL> section in the
> httpd.conf file. This 'PerlSetVar' problem has been fixed in versions
> 1.99_17 and 1.99_19 but those versions have the reload problem that I have
> been encountering -- hence my fallback to the 1.99_12 version.
>
> However, I will follow up on each of your suggestions including downloading
> the source you pointed to and will let you know the results.

Right, I just want you to test this specific problem, so we can single out
the change that affected your code, before we proceed further.



--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas [at] stason http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


vbmonymaker at hotmail

Dec 28, 2004, 7:03 PM

Post #4 of 10 (673 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

>>>If 1.99_16 works and 1.99_17 doesn't that would probably be the change to
>>>blame:
>>>
>>>Added ModPerl::Util::unload_package() to remove a loaded package
>>>as thoroughly as possible by clearing it's stash. [Gozer]
>>>
>>>Please confirm that first. Next let's take some specific module, put it
>>>in
>>>PerlSetVar ReloadModules enable the debug and show us the relevant bits
>>>from the log, so it'll be easier to visualize the problem.
>>>
>>
>>
>>Unfortuantely, I've tried versions 1.99_14, 1.99_15 and 1.99_16 but they
>>all
>>have problems with my use of multiple 'PerlSetVar's when used as part of
>>an
>>array of VirtualHost's that are created within a <PERL> section in the
>>httpd.conf file. This 'PerlSetVar' problem has been fixed in versions
>>1.99_17 and 1.99_19 but those versions have the reload problem that I have
>>been encountering -- hence my fallback to the 1.99_12 version.
>>
>>However, I will follow up on each of your suggestions including
>>downloading
>>the source you pointed to and will let you know the results.
>
>Right, I just want you to test this specific problem, so we can single out
>the change that affected your code, before we proceed further.
>

Okay, mod_perl 1.99_16 reloading works. So the reloading problem starts
with the 1.99_17 version as you suspected. Here is a snippet from my
error_log showing the reloading messages that appear when the Reloading
Debugger is turned on for version 1.99_19:

This is the error_log entry for the module whose changes are not showing up

Apache::Reload: process 22533 reloading Apache::Menus from Apache/Menus.pm
Apache::Reload::handler('Apache::RequestRec=SCALAR(0xc331c20)')
called at /opt/prod/apache/Apache/Menus.pm line 0
eval {...} called at /opt/prod/apache/Apache/Menus.pm line 0

And the following is the error_log entry for a module changed at the same
time whose changes do show up

Apache::Reload: process 22533 reloading Apache::Abracadabra from
Apache/Abracadabra.pm
Apache::Reload::handler('Apache::RequestRec=SCALAR(0xc331c20)')
called at /opt/prod/apache/Apache/Abracadabra.pm line 0
eval {...} called at /opt/prod/apache/Apache/Abracadabra.pm line 0



--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


stas at stason

Dec 29, 2004, 9:13 AM

Post #5 of 10 (685 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Vincent Moneymaker wrote:

> Okay, mod_perl 1.99_16 reloading works. So the reloading problem starts
> with the 1.99_17 version as you suspected.

Perfect. So we most likely know the suspect.

> Here is a snippet from my
> error_log showing the reloading messages that appear when the Reloading
> Debugger is turned on for version 1.99_19:
>
> This is the error_log entry for the module whose changes are not showing up
>
> Apache::Reload: process 22533 reloading Apache::Menus from Apache/Menus.pm
> Apache::Reload::handler('Apache::RequestRec=SCALAR(0xc331c20)')
> called at /opt/prod/apache/Apache/Menus.pm line 0
> eval {...} called at /opt/prod/apache/Apache/Menus.pm line 0
>
> And the following is the error_log entry for a module changed at the
> same time whose changes do show up
>
> Apache::Reload: process 22533 reloading Apache::Abracadabra from
> Apache/Abracadabra.pm
> Apache::Reload::handler('Apache::RequestRec=SCALAR(0xc331c20)')
> called at /opt/prod/apache/Apache/Abracadabra.pm line 0
> eval {...} called at /opt/prod/apache/Apache/Abracadabra.pm line 0

so both modules are located in the same directory, right? Can you reduce
those module to the very minimum while one still reloads and the other
doesn't and post them here, and I'll try to reproduce it here. Also please
past the relevant bits from httpd.conf. Thanks.

--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas [at] stason http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


gozer at ectoplasm

Jan 4, 2005, 10:57 AM

Post #6 of 10 (650 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Stas Bekman wrote:
> Vincent Moneymaker wrote:
>
>>Okay, mod_perl 1.99_16 reloading works. So the reloading problem starts
>>with the 1.99_17 version as you suspected.
>
> Perfect. So we most likely know the suspect.

Possibly a problem with clear_stash()

> [...]
>
> so both modules are located in the same directory, right? Can you reduce
> those module to the very minimum while one still reloads and the other
> doesn't and post them here, and I'll try to reproduce it here. Also please
> past the relevant bits from httpd.conf. Thanks.

I'd like to have look at what code you have in Apache/Menus.pm if that's possible.

Could you also try applying this small debugging patch and try again? Posting
the "[clear_stash]" log lines from your error_log back ?

Index: src/modules/perl/modperl_util.c
===================================================================
--- src/modules/perl/modperl_util.c (revision 124130)
+++ src/modules/perl/modperl_util.c (working copy)
@@ -781,7 +781,13 @@
if (strcmp(this_stash, package) == 0) {
hv_delete(stash, key, len, G_DISCARD);
}
+ else {
+ fprintf(stderr, "[clear_stash] skip foreign entry %s[%s](%s)\n", package, this_stash, key);
+ }
}
+ else {
+ fprintf(stderr, "[clear_stash] skip unsafe entry %s(%s)\n", package, key);
+ }
}
}
}


--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Attachments: signature.asc (0.25 KB)


vbmonymaker at hotmail

Jan 4, 2005, 11:54 AM

Post #7 of 10 (654 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Philippe M. Chiasson wrote:

>Possibly a problem with clear_stash()

>> [...]
>>
>> so both modules are located in the same directory, right? Can you reduce
>> those module to the very minimum while one still reloads and the other
>> doesn't and post them here, and I'll try to reproduce it here. Also
please
>> past the relevant bits from httpd.conf. Thanks.

>I'd like to have look at what code you have in Apache/Menus.pm if that's
possible.

>Could you also try applying this small debugging patch and try again?
Posting
>the "[clear_stash]" log lines from your error_log back ?

Sorry for the slow follow up to Stas, but I've been swamped with work.
Anyway, I will follow up on your suggestions and post the Menus.pm code. I
suspect though that I know what the problem is. Originally, the Menus.pm
module didn't have a declared package name. Only after I ran into the
reload problem did I declare it as being part of the Apache namespace.
Somehow, I think this is what is causing the problem. When I get a chance
(hopefully tonight or tomorrow) I am going to test this theory out by giving
the module a completely different name like Menus2.pm and declaring it from
the start as being part of the Apache namespace.


stas at stason

Jan 4, 2005, 12:10 PM

Post #8 of 10 (668 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Vincent Moneymaker wrote:
> Philippe M. Chiasson wrote:
>
>
>>Possibly a problem with clear_stash()
>
>
>>>[...]
>>>
>>>so both modules are located in the same directory, right? Can you reduce
>>>those module to the very minimum while one still reloads and the other
>>>doesn't and post them here, and I'll try to reproduce it here. Also
>
> please
>
>>>past the relevant bits from httpd.conf. Thanks.
>
>
>>I'd like to have look at what code you have in Apache/Menus.pm if that's
>
> possible.
>
>
>>Could you also try applying this small debugging patch and try again?
>
> Posting
>
>>the "[clear_stash]" log lines from your error_log back ?
>
>
> Sorry for the slow follow up to Stas, but I've been swamped with work.
> Anyway, I will follow up on your suggestions and post the Menus.pm code. I
> suspect though that I know what the problem is. Originally, the Menus.pm
> module didn't have a declared package name. Only after I ran into the
> reload problem did I declare it as being part of the Apache namespace.
> Somehow, I think this is what is causing the problem. When I get a chance
> (hopefully tonight or tomorrow) I am going to test this theory out by giving
> the module a completely different name like Menus2.pm and declaring it from
> the start as being part of the Apache namespace.

But you also indicated that all versions before 1.99_17 did work w/o the
package declaration, so that would be mean a behavior change.

--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas [at] stason http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com


vbmonymaker at hotmail

Jan 4, 2005, 8:28 PM

Post #9 of 10 (676 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Stas Bekman wrote:

>But you also indicated that all versions before 1.99_17 did work w/o the
>package declaration, so that would be mean a behavior change.

First the results. I applied Philippe's patch, but no Reload messages
showed up in the error log when changes were made to the Menus.pm module or
other modules in the same 'Melior' namespace Menus.pm is in. Likewise, when
changes were made to the Abracadabra.pm module (which is in the Apache
namespace) nothing showed up in the error log. However changes made to the
Abracadabra.pm module did show up on the webpages that were being served --
in contrast to changes made in the Menus.pm module which did not show up in
the webpages being served..

Second, the mod_perl download version I was using was mod_perl-2.0.0-RC1 (I
had segmentation faults with the XMas version so I used this version).

Third, I made a slight change from last time when we discussed this problem
by plugging the Menus.pm module into the Melior namespace. I do not think
this is causing the problem however because the Menus.pm module is in the
Melior directory under /opt/prod/apache just as the Abracadabra.pm module is
in the Apache directory under /opt/prod/apache. So both modules have their
respective namespaces declared and are located in their correct directories
-- but only changes made to the Abracadabra.pm module are showing up.

Finally, the changes I made in the Menus.pm module after Apache had started
up were made in the enclosed stripped down version of the module and the
changes made to this version did not show up at all.

Here is the relevant info that was requested:

1. Here are the entries from the httpd.conf file

LoadModule perl_module modules/mod_perl.so
LoadModule php4_module modules/libphp4.so

PerlRequire "/opt/prod/apache/programs/startup.pl"
PerlInitHandler Apache::Reload

2. Here is the stripped down version of the startup.pl file

#!/usr/local/bin/perl -wT
use strict;

BEGIN {
use Apache2 ();
use lib "/opt/prod/apache";
use lib "/opt/prod/apache/nfs";
use lib "/opt/prod/apache/test-mck/mck-cgi";
use CGI::Carp qw(carpout);
open(LOG, ">>/opt/prod/apache/logs/error_log") or die "Unable to append to
/opt/prod/apache/logs/error_log: $! [See the 'startup.pl' program - 1]\n";
carpout(*LOG);
}
# enable if the mod_perl 1.0 compatibility is needed
use Apache::compat ();
use ModPerl::Util (); #for CORE::GLOBAL::exit
use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::RequestUtil ();
use Apache::Server ();
use Apache::ServerUtil ();
use Apache::Connection ();
use Apache::Log ();
use Apache::Reload ();
use APR::Table ();
use APR::URI ();

use ModPerl::RegistryLoader ();
use Apache::Abracadabra ();
use Melior::Menus ();

1;


3. Here is the stripped down version of the Menus.pm module. In this
version, changes that are made to it after Apache has started up still don't
show up in the webpages that are being served.

package Melior::Menus;

use strict;
use locale;
use POSIX 'locale_h';
setlocale(LC_CTYPE, "iso_8859_1");

sub menumain {
my ($r,$my,$id) = @_;
$$my{USERAGENT} = $r->headers_in->get('User-Agent') || '';
my (@field,$name);
print "ab<BR>";
return 1;
}

sub onepagemain {
my ($r,$my) = @_;
$$my{USERAGENT} = $r->headers_in->get('User-Agent') || '';
print "b<BR>";
return 1;
}

sub menutop {
my ($r,$my) = @_;
$$my{USERAGENT} = $r->headers_in->get('User-Agent') || '';
print "c<BR>";
return 1;

}

sub menublank {
my ($r,$my,$id) = @_;
$id ||= 0;
print "d<BR>";
return 1;
}

sub menuleft {
my ($r,$my,$hocuspocus,$id) = @_;
$$my{USERAGENT} = $r->headers_in->get('User-Agent') || '';
print "e<BR>";
return 1;
}


sub deliveries {
my ($my,$id) = @_;
print "f<BR>";
}

sub menusave {
my ($my) = @_;
print "g<BR>";
}

sub user_agency {
my ($r,$my) = @_;
print "h<BR>";
}

sub altogether {
my ($my) = @_;
print "i<BR>";

}

sub layering {
my ($my,$id) = @_;
print "j<BR>";
}

sub content_handler {
my ($r,$my,$id) = @_;
print "k<BR>";
return;
}

1;


gozer at ectoplasm

Jan 5, 2005, 12:17 AM

Post #10 of 10 (676 views)
Permalink
Re: Reloading Modules Problem [mod_perl2] [In reply to]

Vincent Moneymaker wrote:

> Stas Bekman wrote:
>
>> But you also indicated that all versions before 1.99_17 did work w/o
>> the package declaration, so that would be mean a behavior change.
>
> First the results. I applied Philippe's patch, but no Reload messages
> showed up in the error log when changes were made to the Menus.pm
> module or other modules in the same 'Melior' namespace Menus.pm is
> in. Likewise, when changes were made to the Abracadabra.pm module
> (which is in the Apache namespace) nothing showed up in the error
> log. However changes made to the Abracadabra.pm module did show up on
> the webpages that were being served -- in contrast to changes made in
> the Menus.pm module which did not show up in the webpages being served..

Did you try with:

PerlSetVar ReloadDebug On ?

You should at least see in the error_log Apache::Reload telling you
about the modules it's trying to reload. Can you confirm
this ?

But with my patch and not seeing anything reported would tend to
indicate that the original suspicion that it was caused
by the introduction of modperl_package_unload() was wrong...

/me ponders...

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/ F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5
Attachments: signature.asc (0.25 KB)

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.