You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Thorsten Schöning <ts...@am-soft.de> on 2019/07/31 17:33:13 UTC

Syntax errors in case of threaded MPM and lots of concurrent requests.

Hi all,

I'm struggling for 2+ years[1][2] with a problem using mod_perl on
Linux which I was finally able to reproduce on Windows as well. If the
problem occurs, mod_perl is unable to compile my app with all kinds of
weird syntax errors, most likely in the core-libs already. The
following is one example:

> [Mon Jun 05 06:25:23.818862 2017] [core:notice] [pid 21652:tid 139994496042880] AH00094: Command line: '/usr/sbin/apache2'
> String found where operator expected at /usr/share/perl/5.22/Tie/Hash.pm line 25, near "croak "$pkg must define either a TIEHASH() or a new() method""
>   (Do you need to predeclare croak?)
> String found where operator expected at /usr/share/perl/5.22/Tie/Hash.pm line 33, near "croak "$pkg doesn't define a TIEHASH method""
>   (Do you need to predeclare croak?)
> String found where operator expected at /usr/share/perl/5.22/Tie/Hash.pm line 39, near "croak "$pkg doesn't define an EXISTS method""
>   (Do you need to predeclare croak?)
> [Mon Jun 05 16:14:21.233643 2017] [mpm_event:notice] [pid 21652:tid 139994496042880] AH00491: caught SIGTERM, shutting down

Disabling mod_perl makes the problem go away, so syntax errors itself
are pretty unlikely anyway. Additionally even with enabled mod_perl
the error doesn't occur always, only pretty often, but if it occurs
once and some time later not anymore or the other way around it can't
be syntax errors as well from my understanding.

I was able to reproduce the problem on Linux and Windows simply by
using a command like the folllowing:

> ab -n 1000 -c 10 http://localhost/cgi-bin/mandkomm/referenz/mandkomm.pl

I have some authentication handler implemented only consisting of one
package in one file and the same problem happens to that as well.
Whenever too many concurrent requests arrive and a new Perl interpreter
needs to be spawned, things break most likely. If such an interpreter
is already available and reused or it's only one request to be
spawned, things seem to succeed mostly.

What fixes the problem entirely is using "PerlPostConfigRequire" to
load my app during server startup. This solves requesting the above
entry point as well as using my authentication handler.

This leads to the following questions:

1. Does that make sense to anyone at all? :-)
2. Is there some race condition within mod_perl or Perl? Looking at
   the code of mod_perl I saw handling with mutexes and stuff.
3. Any other idea what might cause this issue? My setup doesn't seem
   too unusal, Apache 2.4, threaded MPM, perl-script handler. If that
   wouldn't work I would expect many more problem reports.

Thanks for your time!

[1]: https://superuser.com/questions/1216484/how-to-debug-mod-perl-compilation-errors-during-start-and-reload-of-apache-httpd
[2]: http://mail-archives.apache.org/mod_mbox/perl-modperl/201709.mbox/%3C132805049.20170922171615%40am-soft.de%3E

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: Syntax errors in case of threaded MPM and lots of concurrent requests.

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag John Dunlap,
am Montag, 19. August 2019 um 17:11 schrieben Sie:

> I'm surprised that you're able to use the threaded MPM at all.

As you already said, things seem to heavily depend on the used
packages. Besides the problem introduced at some point I have written
about in this thread, threaded MPM was running mostly successfully for
years. So most of my used packages simply seem to be compatible. I'm
not even sure how the threaded MPM has been introduced, I'm somwhat
sure it was during installing mod_perl using APT at some point.

Additionally, during implementing my workaround I found that it seems
to make a difference when things get loaded as well. For example I'm
loading things now during server startup and Digest::SHA instantly
segfaulted in this scenario, while it didn't in the former setup when
letting mod_perl compile automatically per request as needed. Luckily
I was able to get rid of that package, because it was required only,
not even used at all, by some UUID-generator I didn't need to use
anymore as well.

But for now my app seems to work in threaded MPM again, which would be
a win in supporting Windows. Will see how far I get with it and
hopefully keep switching to prefork in mind. I really didn't think of
that thread-support is that bad in 3rd party Perl packages, despite
the official "deprecated" warning for threads.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: Syntax errors in case of threaded MPM and lots of concurrent requests.

Posted by John Dunlap <Jo...@lariat.co>.
I'm surprised that you're able to use the threaded MPM at all. The only MPM
we're able to make work with our application is prefork. As far as I'm
aware, Perl itself and its core libraries are thread safe but because Perl
spent the last 3 decades without official threading support, most of the
modules on CPAN are not thread safe. Consequently, our application
frequently segfaults when we try to use an MPM other than prefork.

On Mon, Aug 19, 2019 at 8:43 AM Clément OUDOT <cl...@gmail.com> wrote:

> Le mer. 31 juil. 2019 à 19:33, Thorsten Schöning
> <ts...@am-soft.de> a écrit :
> >
> > Hi all,
> >
> > I'm struggling for 2+ years[1][2] with a problem using mod_perl on
> > Linux which I was finally able to reproduce on Windows as well.
>
> Hello Thorsten,
>
> we face the same issues with mod_perl in LemonLDAP::NG
> (https://lemonldap-ng.org/)
>
> We recommend to use mod_perl only with MPM prefork on Apache 2.4.
>
>
>
> Clément.
>


-- 
John Dunlap
*CTO | Lariat *

*Direct:*
*john@lariat.co <jo...@lariat.co>*

*Customer Service:*
877.268.6667
support@lariat.co

Re: Syntax errors in case of threaded MPM and lots of concurrent requests.

Posted by Clément OUDOT <cl...@gmail.com>.
Le mer. 31 juil. 2019 à 19:33, Thorsten Schöning
<ts...@am-soft.de> a écrit :
>
> Hi all,
>
> I'm struggling for 2+ years[1][2] with a problem using mod_perl on
> Linux which I was finally able to reproduce on Windows as well.

Hello Thorsten,

we face the same issues with mod_perl in LemonLDAP::NG
(https://lemonldap-ng.org/)

We recommend to use mod_perl only with MPM prefork on Apache 2.4.



Clément.