mod_perl 2变量和进程损坏

时间:2022-10-05 17:32:54

We've just ported a fairly large codebase from an ancient Perl 5.005.03 CGI environment to mod_perl 2, and now that it's undergoing a public beta there are a few, possibly related, issues we're encountering from time to time. These build up until we have to restart the server.

我们刚刚将一个相当大的代码库从一个古老的Perl 5.005.03 CGI环境移植到mod_perl 2,现在它正在进行公开测试,但我们不时会遇到一些可能相关的问题。这些构建直到我们必须重新启动服务器。

All of our code compiles under use strict, but has been previously called as a compiled, run and discarded CGI script. Problems we've encountered so far: setting $| or calling STDOUT->autoflush(1); using old-style global filehandles (open(ERRORFILE, $errorfile) rather than open(my $fh_error, $errorfile)). Also calling system() - shortly after we started the public beta, we spotted e.g. /bin/tail or /usr/sbin/sendmail listening on ports 80 and 443, which stopped the server from being restarted. I've since rewritten that code to use pure-Perl methods, and we no longer have that problem.

我们所有的代码都在use strict下编译,但之前被称为编译,运行和丢弃的CGI脚本。到目前为止我们遇到的问题:设置$ |或者调用STDOUT-> autoflush(1);使用旧式全局文件句柄(打开(ERRORFILE,$ errorfile)而不是打开(我的$ fh_error,$ errorfile))。同样调用system() - 在我们开始公开测试版后不久,我们发现了/ bin / tail或/ usr / sbin / sendmail侦听端口80和443,这会阻止服务器重新启动。我已经重写了该代码以使用纯Perl方法,我们不再有这个问题。

Two issues remain. The first one is that the logs are full of mod_perl complaining about constants having been redefined, e.g.

还有两个问题。第一个是日志中充满了mod_perl抱怨已经重新定义的常量,例如

Constant subroutine ModPerl::ROOT::ModPerl::PerlRun::usr_local_..._cgi_forgotpassword::O_CREAT redefined at /usr/lib/perl5/ModPerl/Util.pm line 69.

Also, occasionally seemingly core variables will get trashed. One of our core in-house modules logs information about the PID and name of the script, and produced information like this:

此外,偶尔看似核心变量将被破坏。我们的核心内部模块之一记录有关PID和脚本名称的信息,并生成如下信息:

20090202-233948-32154:Started script /usr/local/.../cgi/account/renewalcalendar
20090202-233948-32154:Ended script /usr/sbin/apache2

At other times the process ID will end up as undef. This is rare and intermittent.

在其他时候,进程ID最终将为undef。这是罕见的和间歇性的。

Secondly, and also intermittently, we will occasionally see garbage collection not kick in. (Perhaps an issue of weak references? But nearly all of the time everything works fine.) The most immediate symptom of this is database handles opened that are never closed, but when I delve deeper into the issue, it becomes apparent that there's a DBI object stored in a standard Perl hash object, and that object's DESTROY method is (rarely and intermittently) not called.

其次,也是间歇性地,我们偶尔会看到垃圾收集没有启动。(也许是一个弱引用问题?但几乎所有时候一切正常。)最直接的症状是打开的数据库句柄永远不会关闭,但是当我深入研究这个问题时,很明显有一个DBI对象存储在一个标准的Perl哈希对象中,并且该对象的DESTROY方法(很少和间歇性地)没有被调用。

We're running Debian 5.0 (Lenny), Perl 5.10.0, Apache 2.29, mod_perl 2.0.4, openSSL 0.9.8g. I can provide more information if necessary, but I think that's the basics.

我们正在运行Debian 5.0(Lenny),Perl 5.10.0,Apache 2.29,mod_perl 2.0.4,openSSL 0.9.8g。如有必要,我可以提供更多信息,但我认为这是基础知识。

The salient parts of the apache config, being /etc/apache2/sites-enabled/*sitename*, are (some bits redacted for confidentiality reasons):

apache配置的显着部分是/ etc / apache2 / sites-enabled / * sitename *,(由于机密性原因,有些位被编辑):

<VirtualHost ...:443>
<Directory />
    Options SymLinksIfOwnerMatch
    AllowOverride None
</Directory>
<Directory /usr/local/.../cgi>
    SetHandler perl-script
    PerlResponseHandler ModPerl::PerlRun
    PerlOptions +ParseHeaders
    Options +ExecCGI
</Directory>
</VirtualHost>

There's some SSL, rewrites and redirection stuff going on there, but that's the important stuff.

那里有一些SSL,重写和重定向的东西,但这是重要的东西。

Does this sound familiar to anyone? Alternatively, can anyone recommend any way of debugging the problem further?

这听起来对任何人都很熟悉吗?或者,任何人都可以推荐任何进一步调试问题的方法吗?

1 个解决方案

#1


For your memory problem: you need to call weaken (from standard module Scalar::Util)

对于你的内存问题:你需要调用weaken(来自标准模块Scalar :: Util)

#1


For your memory problem: you need to call weaken (from standard module Scalar::Util)

对于你的内存问题:你需要调用weaken(来自标准模块Scalar :: Util)