debian sarge packages in a production environment
hi list, i'd like to know if it is okay to use debian sarge's apache-perl package for a production environment or if i'd be better of rebuilding everything including perl (as debian's perl comes with ithreads support)? I've read that a perl interpreter with ithreads enabled is about 10-15% slower than without threads support - even when not using threads in your applications at all. is this still true? thanks for helping! toby --- email services provided by http://www.funkreich.de
Weird Apache/DBI problems
Hi list, I recently transferred our application to a more powerful server running debian 3.1. As always I compiled the important parts (perl 5.8.7 without threads and apache 1.3.34/mod_perl plus a lot of cpan modules) myself. Our application (which uses Mason) ran fine for the last 3 years on all kinds of setups (including debian 3.1) but on the new machine the apache is currently running wild. As soon as more than one parallel request is made I immediately get unexplainable DBI errors like "fetch() without execute()", "DBD driver has not implemented the AutoCommit attribute" or "Commands out of sync; you can't run this command now". These messages do not appear when running httpd in single-server mode (-X). I have removed debian's apache and cpan packages and recompiled everything - but that didn't help either. So far I've tried a MySQL 5.0 binary from mysql.com and the 4.1.11 one provided by debian. Any idea on what could cause this or where to look for more information is greatly appreciated! Thanks a lot! Toby --- email services provided by http://www.funkreich.de
Re: Weird Apache/DBI problems
Zitat von Perrin Harkins <[EMAIL PROTECTED]>: > On Thu, 2005-12-22 at 16:00 +0100, Tobias wrote: > > As soon as more than one parallel request is made I immediately get > > unexplainable DBI errors like "fetch() without execute()", "DBD driver > > has not implemented the AutoCommit attribute" or "Commands out of sync; > > you can't run this command now". These messages do not appear when running > > httpd in single-server mode (-X). > > Most likely you are making a DBI connection during startup, putting it > in a global, and using it from multiple child processes. If you have > this system running safely on another machine, figuring out what code > you changed is a good place to start. Apache::DBI tries to prevent > this, but it can't stop you from putting a $dbh into a global yourself. I'm establishing a database connection in my mod_perl handler sub routine making it globally available using Mason's allow_globals feature. That always worked for me (until now :)) The weird thing is that I just rsync'd the code over from another debian system on which the application runs just fine. The only difference (as far as I can see) to the failing system is a debian Perl 5.8.4 (with threads) instead of a self-compiled threadless Perl 5.8.7. Any other ideas? Thanks again for your help! Toby --- email services provided by http://www.funkreich.de
Re: the perl scripts are not executed on server side
Zitat von Eric GRAMMATICO <[EMAIL PROTECTED]>: > When I connect to http://localhost/perl/rocks.pl the browser shows the > source code. I believe I have a miss configuration somewhere, but I > didnt find. Here is the alias part of my /etc/httpd/conf.d/perl.conf: > > Alias /perl/ /var/www/perl/ > Just a guess: Make this and see if that helps! Toby
Re: mod_perl and mysql
I'm quite sure that this happens because you're using mod_perl AND php compiled into the same apache. I've been running into this kind of trouble several times (on different machines with different apache/mod_perl/php versions - mod_perl was always compiled statically. I tried php statically and dynamically with built-in mysql-support and linked to my installed mysql libraries - nothing helped). I finally gave up on this and am now running two separate apache servers (one for php, one for mod_perl) on my machine which kinda sucks :( -- Cheers, Tobias Zitat von Global Junk <[EMAIL PROTECTED]>: > I'm running Linux Apache/1.3.26 (Unix) mod_perl/1.26 > PHP/4.2.3 and MySQL. > > I'm trying to write a simple web (perl) application > that accesses a mysql database. I'm using DBI(). > When I access the site under normal Perl it works. > When I access the site under Mod_Perl I get: > > child pid 20524 exit signal Segmentation fault (11), > possible coredump in /usr/local/apache > > Does anyone have any ideas or links to help with > Mod_Perl and MySQL running together? > > Thanks. > > __ > Do you Yahoo!? > Protect your identity with Yahoo! Mail AddressGuard > http://antispam.yahoo.com/whatsnewfree > > -- > Reporting bugs: http://perl.apache.org/bugs/ > Mail list info: http://perl.apache.org/maillist/modperl.html > > > --- http://www.funkreich.de // may the funk be with you -- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html
Re: [slightly OT] Catalyst? Maypole?
Zitat von Daniel McBrearty <[EMAIL PROTECTED]>: > I've been looking around at MVC frameworks a bit recently. RoR looks > good if you don't mind the language switch, but I'm also looking at > these two. Anyone have much experience of them, in tandem with > mod_perl? Feedback and thoughts? Catalyst is really nice. I'd definitely recommend you spend some time with it. AFAIK it is partly based on maypole with a much increased feature set and a slightly different approach. Basically I like the idea of catalyst being just some sort of glue framework that links whatever cpan module you like to use for your Model and View. The included (perl) test server makes it very easy to start developing with it and it works well with mod_perl if you decide to put it into production. HTH, Toby --- email services provided by http://www.funkreich.de
Re: the modperl book link is broken
Ken Perl wrote: > their links http://modperlbook.org/ ... are both broken modperlbook.org works fine for me, try it again ... TR
Crypt::OpenSSL::X509
Hi all, for my current project I have to deal with client certificates. Therefor I installed Crypt::OpenSSL::X509, but yet "make test" failed for issuer() and subject(). The values returned are always empty. Has anyone experienced the same problems? Here's my configuration: Perl v5.8.0 OpenSSL v0.9.6g Crypt-OpenSSL-X509-0.3.1 Sorry for the not modperl-related post, but I hope here's someone who can help me. Thanks, Tobias -- Tobias Regneri mailto:[EMAIL PROTECTED]
(Database-)Object initialization during server-startup
Hey guys, I'm wondering what's the best way to design a database-backed module which works completely on its own as well as within mod_perl (mp1). The module should make a database connection during object initialization (new). This connection should then be used by all methods which want to access the database (because I don't want to call "connect" before every database query). That's easy under standalone conditions (connect within new, store the dbh in $self->{_dbh} and use that in other methods). Enter mod_perl. I'd like to create the object only ONCE during server startup because it has to do some fairly heavy processing with data from the database which I don't want to be done on every request. The resulting state (some data structures) should then be saved within the object's attributes for later quick and easy retrieval during the request phase. Furthermore this object has methods which execute more database queries (using the handle stored in $self->{_dbh}). Now here's my concern: Because Apache::DBI will not cache the database handle that was created during startup (some mechanisms luckily prevents this), I fear that I might run into trouble having requests using the object generated at server startup with a non-cached handle inside that is shared among all apache children. I know that one should connect in the request phase and let Apache::DBI do the magic, but in this case, where the module is designed to be also used standalone, this is quite tricky IMHO. Hope you get the problem! Any ideas? Thanx a lot! Toby
Re: (Database-)Object initialization during server-startup
Zitat von Perrin Harkins <[EMAIL PROTECTED]>: > You need to separate managing your database connections from caching > this data. They are not related, and there's no reason to do both in > one class. Either just call connect_cached all the time (it uses > Apache::DBI when it finds it loaded), or make your own database > connection singleton that decides how to connect in the current > environment. Keep your data in the object as you planned. Ok, got that! But how does the class get its database handle to operate on? I have already put the database connection stuff into a separate class (let's call it My::Database). My::Database has a constructor which connects to the database, stores the handle in $self->{_dbh} and a method "dbh" which returns this handle. Now My::Structure does the following: sub new { ... $self->{_dbh} = My::Database->new()->dbh(); ... } sub init { ... prepare data using $self->{_dbh} and store it ... } sub query_something_during_request { ... again using $self->{_dbh} ... # this is where a "stale", non-cached database handle will get used, right? } One solution that just popped into my mind is changing My::Database's "dbh" method so that it always connects using connect_cached instead of doing it once during creation of My::Database. Would that be a feasible solution? Again thanx a lot! Toby
Re: (Database-)Object initialization during server-startup
Zitat von Perrin Harkins <[EMAIL PROTECTED]>: > > Create a new instance of the mod_perl handler module during startup and > > refer to that for the handlers (code below). > > This module would then cache DB connections and provide a method for > > 'create or fetch current DB connection'. > > DBI->connect_cached will do all of this for you. Yeah, looks like connect_cached coupled with a different way of obtaining the database handle is the solution for my problem, too. Works perfectly! Thanks a lot, Perrin! Toby
Re: [mp2] *** glibc detected *** double free or corruption (fasttop)
Hi Andreas, if you're using the Debian supplied packages for apache2, perl and mod_perl I'd try compiling them manually and see if that helps. This will also give you a Perl interpreter without threads (which have a negative impact on performance AFAIK). HTH, Tobias :) Zitat von Andreas Dembach <[EMAIL PROTECTED]>: > > Hello list, > > I am experiencing memory allocation problem reported by glibc when > running a web application under mod_perl2: > > > 1. Problem Description: > > When hitting our web application with more than one concurrent request > (using ApacheBench), very soon errors like > > *** glibc detected *** double free or corruption (fasttop): 0x08d7a318 *** > *** glibc detected *** corrupted double-linked list: 0x40544a8c *** > *** glibc detected *** double free or corruption (fasttop): 0x4585d630 *** >
Re: Memory Usage
I suggest taking a look at the excellent mod_perl performance guide: http://perl.apache.org/docs/1.0/guide/performance.html -- Tobias Zitat von "Daniel B. Hemmerich" <[EMAIL PROTECTED]>: > We are concerned about how much memory we are using now that we are moving > to modperl. > > > > Are there any good tools/procedures that we could use to determine how much > memory our application is currently using - and then using that as a > benchmark, determine how much more or less memory we are using after making > changes to our application? > > > > This is not directly a modperl question - but maybe there are some handy > tools that are closely tied to modperl. > > > > Thanks in advance! > >
[JOB] Perl/mod_perl Web Developer in Cologne, Germany
urbia.com AG is looking for an experienced Perl/mod_perl Web developer (full-time) to support the development of our successful online community at www.urbia.de. More information (in German only) about the job can be found at: http://www.urbia.de/general/jobs/ -- Kind regards Tobias Kremer CTO urbia.com AG Friedrichstraße 42-44 50676 Köln Telefon 02 21 / 29 49 - 154 Telefax 02 21 / 29 49 - 599 E-Mail [EMAIL PROTECTED] http://www.urbia.de - we are family
SOPE::Lite / prcessing complex data types at server side
Hi List, currently I'm developing a soap server with SOAP::Lite. Now i ran into trouble because I use an own schema with complex data types. On client side everything works fine. Now I try to handle the generated requests on the server side. But I can't figure out how the deserializer presemts me the parsed information. I try to process the following request: http://www.w3.org/2001/XMLSchema-instance"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";> MyProvider MyGroup Attribute1 Value1 Attribute2 Wert2 If I use the following handler package MyService; sub AddGroupAttributes { ($self, $provider, $group, $attrlist) = @_; ($name, $hashref) = split('=', $attrlist); $params = $$hashref; ... } the variables $provider and $group are set correctly but the hash for the list items is empty. Do I have to override the deserializer (if yes, is there any documentation available) or am I handling the parameters in the wrong way? I would appreciate if someone could point me in the right direction. Thanks, Tobias
Re: SOPE::Lite / prcessing complex data types at server side
Robert Landrum wrote: > I would use Data::Dumper; warn(Dumper([EMAIL PROTECTED])); and see what's in > the logs. Thanks for your hint. DataDumper says: (eval): MyProvider MyGroup attrList=HASH(0x517834) $VAR1 = \'MyProvider'; $VAR1 = \'MyGroup'; $VAR1 = \bless( { 'listItem' => [ bless( { 'attrVal' => 'Wert1', 'attrName' => 'Attribute1' }, 'attrItem' ), bless( { 'attrVal' => 'Wert2', 'attrName' => 'Attribute2' }, 'attrItem' ) ] }, 'attrList' ); But I still can't figure out how to process the data in my handler. The first two Parameters are trivial ($_[1] and $_[2]). If I try to access the third value (see first line -> attrList=HASH(...)) I only retrieve an empty hash. Correct me if I'm wrong, but I understand the above list as follows: The hash with name attrList contains the key listItem with an anonymous array as value. The array itself contains two hashes each with the two keys attrVal and attrName. How can I access these values? Thanks a lot. Tobias
Re: SOAP::Lite / processing complex data types at server side
Raf wrote: > A quick test might be to change warn([EMAIL PROTECTED]) to: > warn($_[2]->{listItem}->[0]->{attrVal}) and see if you get 'Wert1'? Thanks for your reply, Ralf. Finally, I got it to work an hour ago. I try no more to access the parameters directly but with help of the SOAP::Server object. Because it took me days of reading, testing and 'googling' I want to share my solution with the list. Perhaps it'll save somebody's time. Given the following xml structure of the data to process Name1 Val1 Name2 Val2 SOAP::Lite will build the internal representation $VAR1 = [ bless( { 'ListItem' => [ bless( { 'Name' => 'Name1', 'Value' => 'Val1' } ), bless( { 'Name' => 'Name2', 'Value' => 'Val2' } ) ] }, 'List' ) ]; To access this data structure you can use the 'valueof' method from the SOAP::SOM class, eg: use SOAP::Lite; SOAP::Transport::HTTP::CGI -> dispatch_to('MySOAPService') -> handle; BEGIN { package MySOAPService; use strict; use vars qw(@ISA); @ISA = qw(SOAP::Server::Parameters); sub ListHandler { my $self = shift; my $envelope = pop; my $i = 0; for my $item ($envelope->valueof("//ListHandler/List/ListItem")) { $ListItemName = $item->{Name}; $ListItemValue = $item->{Value}; # ... $i++; } return SOAP::Data->name("ItemCount" => $i); } } That's all. Regards Tobias
PerlRequire executed 4 times on apache startup
Hi all, I have a weird problem: on startup apache executes 4 times a Perl Script I included via PerlPostConfigRequire startup.pl in the httpd.conf. The startup script contains following code: #!/usr/bin/perl my $file = 'c:\tmp\test.txt'; open(INFO ,">>$file") || die "Error $!"; print INFO "test\n"; close INFO; print STDERR "test...\n"; 1; After starting the apache server (with an empty test.txt) the error.log contains as expectet one time "test..." and the test.txt contains curiously four times "test". That means apache has executed the startup.pl four times. I have found http://modperlbook.org/html/ch04_07.html but that "apache config test" would only explain the execution of two times. Actually the startup.pl contains some code for preloading a huge amount of modules, so this needs about 10 seconds instead of 2 or 3. Hope anybody knows or can explain this behaviour. Thanks and best regards Tobi
Re: Question...
Hi Tyler, I don't think that your script causes the issue. Is there a timeout value set in the httpd.conf? Hth, Tobias
Re: Question...
Hi Tyler, I gave your script a test run on an apache 1.3 and had the same effect (blank page). I then modified the script as follows and everything was fine. #!/usr/bin/perl -w my $time = 65; for(my $i = 0; $i < $time; $i++) { warn("iteration..." . $i); sleep(1); } print "Content-type: text/html\n\n"; print "Test"; print("version 2.x suceeded!!!"); print ""; 1; I think apache2/mp2 automatically sends a header and apache 1.3 doesn't. It's only a guess cause I don't have any experiences with apache2. Tobias
Re: Apache offers to download the perl script rather than execute it!
Hi, > SetHandler perl-script I think it's only a missing file type SetHandler perl-script .pl Hth, Tobias
Segfault when connecting during Apache startup with Apache::DBI
gest/SHA1/SHA1.so Reading symbols from /usr/lib/perl/5.8.8/auto/Storable/Storable.so...done. Loaded symbols for /usr/lib/perl/5.8/auto/Storable/Storable.so Reading symbols from /usr/lib/perl/5.8.8/auto/Digest/MD5/MD5.so...done. Loaded symbols for /usr/lib/perl/5.8/auto/Digest/MD5/MD5.so Reading symbols from /usr/local/lib/perl/5.8.8/auto/DBD/mysql/mysql.so...done. Loaded symbols for /usr/local/lib/perl/5.8.8/auto/DBD/mysql/mysql.so Reading symbols from /usr/lib/libmysqlclient.so.15...done. Loaded symbols for /usr/lib/libmysqlclient.so.15 Reading symbols from /lib/tls/i686/cmov/libnsl.so.1...done. Loaded symbols for /lib/tls/i686/cmov/libnsl.so.1 Reading symbols from /usr/lib/libz.so.1...done. Loaded symbols for /usr/lib/libz.so.1 Reading symbols from /lib/tls/i686/cmov/libnss_files.so.2...done. Loaded symbols for /lib/tls/i686/cmov/libnss_files.so.2 Reading symbols from /lib/libnss_mdns4_minimal.so.2...done. Loaded symbols for /lib/libnss_mdns4_minimal.so.2 Reading symbols from /lib/tls/i686/cmov/libnss_dns.so.2...done. Loaded symbols for /lib/tls/i686/cmov/libnss_dns.so.2 Reading symbols from /lib/tls/i686/cmov/libresolv.so.2...done. Loaded symbols for /lib/tls/i686/cmov/libresolv.so.2 Reading symbols from /usr/lib/apache/1.3/mod_log_config.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_log_config.so Reading symbols from /usr/lib/apache/1.3/mod_mime_magic.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_mime_magic.so Reading symbols from /usr/lib/apache/1.3/mod_mime.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_mime.so Reading symbols from /usr/lib/apache/1.3/mod_dir.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_dir.so Reading symbols from /usr/lib/apache/1.3/mod_alias.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_alias.so Reading symbols from /usr/lib/apache/1.3/mod_rewrite.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_rewrite.so Reading symbols from /usr/lib/apache/1.3/mod_access.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_access.so Reading symbols from /usr/lib/apache/1.3/mod_setenvif.so...done. Loaded symbols for /usr/lib/apache/1.3/mod_setenvif.so Reading symbols from /lib/tls/i686/cmov/libnss_compat.so.2...done. Loaded symbols for /lib/tls/i686/cmov/libnss_compat.so.2 Reading symbols from /lib/tls/i686/cmov/libnss_nis.so.2...done. Loaded symbols for /lib/tls/i686/cmov/libnss_nis.so.2 Core was generated by `/usr/sbin/apache-perl'. Program terminated with signal 11, Segmentation fault. #0 0xb775a89b in mysql_ping () from /usr/lib/libmysqlclient.so.15 So it fails during the call to mysql_ping() but I can't see why this is happening. Any ideas? Thanks! --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
> - Ubuntu Feisty with apache-perl. > - stock Ubuntu Perl 5.8.8 (which unfortunately comes with threads) > - self-rolled DBD::mysql (against libmysqlclient15-dev), DBI and Apache::DBI I should have mentioned that we're using DBI 1.605, Apache::DBI 1.07 and DBD::mysql 4.007. The Ubuntu apache-perl package consists of Apache 1.3.34 and mod_perl/1.29. --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
Quoting Tobias Kremer <[EMAIL PROTECTED]>: > > - Ubuntu Feisty with apache-perl. > > - stock Ubuntu Perl 5.8.8 (which unfortunately comes with threads) > > - self-rolled DBD::mysql (against libmysqlclient15-dev), DBI and > Apache::DBI > > I should have mentioned that we're using DBI 1.605, Apache::DBI 1.07 and > DBD::mysql 4.007. The Ubuntu apache-perl package consists of Apache 1.3.34 > and > mod_perl/1.29. After de-installing the latest (self-rolled) DBI and DBD::mysql modules and installing the corresponding packages provided by Ubuntu (libdbd-mysql-perl and libdbi-perl) the segfaults are gone. Anyone know what could have gone wrong during make'ing my own DBI/DBD::mysql? I'd really like to use the most current versions of those two modules instead of the outdated Ubuntu ones (DBI 1.53, DBD::mysql 3.0008). --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
Quoting André Warnier <[EMAIL PROTECTED]>: > I don't know if the above versions are imposed to you, but in case you > have a choice, I would recommend de-installing your Apache and mod_perl, > and re-install the Apache 2.2 version and the mod_perl that goes with it. > Apache 1.x and mod_perl 1.x are old versions, and you will have trouble > finding someone able to help you. Unfortunately, switching to Apache2/mod_perl2 is not an option at this time :( Besides, I doubt that everyone here already erased their entire mod_perl 1 knowledge. Where are my old-hands? ;-) --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
On 25.06.2008, at 20:58, Amiri Barksdale wrote: I had big trouble with DBD::mysql 4.007. I didn't get rid of my segfault problem running mod_perl 1.31 until I went back to 4.004. Thanx. It really looks a lot like my problem: http://bugs.mysql.com/bug.php?id=36810 I'll try reverting to an earlier version of DBD::mysql. --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
Quoting Tobias Kremer <[EMAIL PROTECTED]>: > On 25.06.2008, at 20:58, Amiri Barksdale wrote: > > I had big trouble with DBD::mysql 4.007. I didn't get rid of my > > segfault problem running mod_perl 1.31 until I went back to 4.004. > > Thanx. It really looks a lot like my problem: > > http://bugs.mysql.com/bug.php?id=36810 > > I'll try reverting to an earlier version of DBD::mysql. The latest DBD::mysql really seems to be the culprit. Even on a freshly installed Ubuntu 8.04 with the stock Perl 5.8.8 but self-compiled MySQL 5.0.51a, Apache 1.3.41, mod_perl 1.30, DBI 1.605 and DBD 4.0007 I'm getting segmentation faults. After installing DBD 4.0004 everything works fine. Of course, I made sure that the correct MySQL library was linked. I can't understand what 4.0007 is still doing on CPAN as the most recent version. But maybe this still is an Ubuntu and/or MP1 related thing - even with most components rolled by myself ... Now if I could just get rid of those annoying random "Commands out of sync" and "Lost connection to MySQL server during query" errors that happen once in a while ... --Tobias
Re: Segfault when connecting during Apache startup with Apache::DBI
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > On Fri, Jun 27, 2008 at 5:51 AM, Tobias Kremer <[EMAIL PROTECTED]> wrote: > > Now if I could just get rid of those annoying random "Commands out of sync" > and > > "Lost connection to MySQL server during query" errors that happen once in a > > while ... > Those generally mean that you timed out (set MySQL's timeouts longer) > or did something incorrectly with forking. We never fork and I thought that Apache::DBI takes care of checking if a connection went stale by utilizing DBI's/DBD::mysql's ping() method? Sometimes I'm also seeing this error seconds after restarting the mod_perl Apache - I think that there should be only fresh connections then ... Any other ideas? Thanks! --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > On Mon, Jun 30, 2008 at 4:54 AM, Tobias Kremer <[EMAIL PROTECTED]> wrote: > > We never fork and I thought that Apache::DBI takes care of checking if a > > connection went stale by utilizing DBI's/DBD::mysql's ping() method? > It does, but it can't stop you from doing things like putting a > database handle in a global during startup and trying to use it later. Ok, I narrowed it down to the database connection initiated during server startup. As soon as I remove it the errors vanish completely. But I don't understand why this is causing a problem because Apache::DBI is supposed to not cache connections made during server startup - it even correctly issues a warning. Here are some snippets to illustrate what I'm doing: --- ApacheHandler.pm --- use Apache::DBI; { package HTML::Mason::Commands; use vars qw/ $thefoo /; } my $foo = My::Foo->new(); sub handler { $HTML::Mason::Commands::thefoo = $foo; } --- My/Foo.pm --- sub new { my $dbh = My::Database::dbh(); my $result = $dbh->selectall_arrayref( ... ); # create an object of e.g. My::Bar initialized with row data # and store it in $self. $dbh is never stored somewhere! $dbh->disconnect(); } --- My/Database.pm --- use DBI; sub dbh { DBI->connect( ... ) } Any ideas? Thanks a lot! --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > I don't see anything in this code, but you're not really showing us > much here. I think you'll need to try commenting out parts of it > until you find which part breaks it. I'd start with that > selectall_arrayref that you store. I can reproduce the problem with the following minimal setup: package LostHandler; use Apache::DBI; use DBI; use LostDatabase; use LostFoo; use vars qw( $dbh $thefoo ); my $foo = LostFoo->new(); sub handler { $thefoo = $foo; $dbh = LostDatabase::dbh(); $dbh->do( "SELECT 1" ); return 200; } 1; --- package LostFoo; use LostDatabase; sub new { my $self = {}; my $dbh = LostDatabase::dbh(); $dbh->do( "SELECT 2" ); $dbh->disconnect(); bless $self, shift; } 1; --- package LostDatabase; sub dbh { DBI->connect('dbi:mysql:test','','') } 1; Hammering this with "ab -n 1000 -c 30" gives me the "Lost connection" and/or "DBD driver has not implemented the AutoCommit attribute" error after the first couple of requests. Removing the lines: my $foo = LostFoo->new(); $thefoo = $foo; makes the error disappear completely. I've had this problem on many systems and never really bothered because it only shows up on our rather busy system after the server gets restarted but somehow it gives me headaches to not know where it is coming from ... --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Michael Peters <[EMAIL PROTECTED]>: > Tobias Kremer wrote: > > use vars qw( $dbh $thefoo ); > Why are you storing the DB handle in a global variable? > If you do that then Apache::DBI can't help you if the connection goes away. To make this variable available to all Mason components. Theoretically, this shouldn't be a problem because I'm (re-)connecting on every request in the handler() subroutine not once during startup. Actually it works perfectly as soon as you remove the one-time connection made during startup (LostFoo) which just preloads some data from the database. According to the docs Apache::DBI should automatically avoid caching this connection. --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
On 30.06.2008, at 17:10, Perrin Harkins wrote: It's not Apache::DBI that's caching it -- you're caching it. Don't put a database handle in a global before you fork. It will stay, and there's nothing Apache::DBI can do about it. Could you please show me the exact line in my example in which I put the database handle in a global during startup? To me it looks like I'm correctly _declaring_ a global variable ($dbh) on server startup, but the connect happens in the handler() subroutine. There's even an example in the Mason docs that recommends this approach: http://masonhq.com/?FAQ:ServerConfiguration#h-how_do_i_connect_to_a_database_from_mason_ And this all works great - without _any_ errors at all! It's not until I start adding my preloading stuff which fetches some stuff from the database during startup with a supposedly independent not-cached handle which should have got nothing to do with my global $dbh that the errors crop up. Thank you very much! :) --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > On a closer look, you're not. You are keeping around your $foo > closure variable in handler(), as well as putting it in a global. > It's not obvious why that causes this problem. If you want to > determine whether Apache::DBI is malfunctioning for you in some way, > I'd suggest just removing it and seeing if the problem goes away. > Your test app should work fine without it. Removing Apache::DBI makes the errors go away. Using two different connection strings for my initial connection during startup and the subsequent connections in the handler() method also works. So everything looks like the connection made during startup is indeed re-used somehow, although Apache::DBI correctly reports that it won't cache it. Maybe now's the time to file a bug report ... --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > Ok. First, check that you're on the latest version. Then, turn on > the debug flag and see if it thinks it is reusing the startup > connection or not. Yes, I'm using the latest 1.07 release. I already had the debug flag on and it's correctly telling me that it's "skipping connection during server startup". --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > Yes, but what does it tell you on the first connection AFTER startup? > It should say whether it's making a new connection or not. Here's the complete debug output which suggests that the connection during startup is reused for the first request. On server start: 20097 Apache::DBI skipping connection during server startup, read the docu !! 20097 Apache::DBI push PerlCleanupHandler 20097 Apache::DBI need ping: yes 20097 Apache::DBI new connect to 'foo:bar...' 20097 Apache::DBI disconnect (overloaded) On first request: 20099 Apache::DBI need ping: yes 20099 Apache::DBI already connected to 'foo:bar...' 20099 Apache::DBI PerlCleanupHandler --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Perrin Harkins <[EMAIL PROTECTED]>: > How are you loading this? With a PerlModule call? Can you try > loading it from a Perl section like this? > > use MyModule; > Wow, it seems that this fixes the problem! At least with my minimal application. Here's the debug output which looks quite promising IMHO: On server start: 8816 Apache::DBI skipping connection during server startup, read the docu !! [rest is gone!] On first request: - 8818 Apache::DBI push PerlCleanupHandler 8818 Apache::DBI need ping: yes 8818 Apache::DBI new connect to 'foo:bar' 8818 Apache::DBI PerlCleanupHandler This comes up a couple of times for every new process and afterwards changes to "already connected" which is exactly the behaviour I expected in the first place. Do you have any idea what is going on? I'll check out how our real system behaves with this change. Thanks a lot, Perrin! --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
Quoting Tobias Kremer <[EMAIL PROTECTED]>: > Quoting Perrin Harkins <[EMAIL PROTECTED]>: > > How are you loading this? With a PerlModule call? Can you try > > loading it from a Perl section like this? > > > > use MyModule; > > > Wow, it seems that this fixes the problem! > Do you have any idea what is going on? I'll check out how our real system > behaves with this change. No more errors there either! :) I don't know anything about the internals but to me the mod_perl source looks like PerlModule is using "require" instead of "use" to load modules. I guess that is making the difference? Whatever the cause is, I think it should be documented somewhere. I'd happily provide a doc-patch for whatever documentation is suitable :) --Tobias
Re: Lost connection to MySQL server during query (was "Segfault when connecting during Apache startup")
> I don't know the details, but there is something about the way > PerlModule works in mod_perl 1 that causes it to load the module again > when apache restarts at startup (it runs yours conf file twice when > you start, as documented). Using an explicit use() puts an entry in > %INC and fixes the issue. This should happen with require() as well, > so I don't know what the problem is, but I've been told that mod_perl > 2 doesn't have this problem. So, due to this being the mod_perl list there must be somebody here who knows what's going on deep down in the guts of the beast :) > There seems to be an additional bug in either Apache::DBI or mod_perl > 1, since $Apache::ServerStarting == 1 seems not to be true the second > time through. Can you have your Perl section print out the values of > $Apache::ServerStarting and $Apache::ServerReStarting? This gives me: Apache::ServerStarting = 1 Apache::ServerReStarting = 0 once(!) on server startup - no matter if I "use" my handler or load it via PerlModule. --Tobias
Need help with abort connection
Hello, I'm using > apache 2.2.3 > mod_perl 2.0.2 > mod_apreq2 2.08 on a linux box. In my enviroment a user can submit a query to a database. This request is handled as an Ajax-request. If he forget to add some search parameters this query can run a long time. So I add a "Cancel"-Button to the frontend that abort the request. That will work with no problems. But on the server side the request/query keeps on running. My handler first collect all data and then send the header and print the content. Because the handler works for Ajax and "normal" Requests and first after finishing the complete request I can decide if the "Content-Type" is html/pdf/json/xml/etc. Can someone give me a hint or better a solution how I can abort the request on the server side, too. Please excuse my english, but I hope you understand my question ;-) Best regards, Tobias
Very special handler
Hello, my config: Apache/2.2.16 (Debian) mod_ssl/2.2.16 OpenSSL/0.9.8o mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1 I have a very large project based on mod_perl and sometimes a process is running "wild". But I can't identify which one it is, because on my development plattform this does not happend, only on the productive system. So I write a small handler (see below) which I init with PerlChildInitHandlerHandler::SigUSR2->childInit PerlTransHandlerHandler::SigUSR2->requestInit With this handler I can send a kill -USR2 to the apache2 process that's running "wild" and the sighandler writes the URI to the apache error_log. My question is now, if someone who knows linux/apache/mod_perl better than me, can take a look at the handler and can tell me if this is dangerous or time consuming. On my development system I can't regocnize anything that took longer or so, but before transfering this code to the productiv system I will be sure, that nothing can happen. Or, perhaps, someone can tell me another way to get the request an apache process is currently handling. Thanks for your help! Regards Tobias code here - package Handler::SigUSR2; # Created: 2010-09-03 08:13:42 # SVN: $Id$ use strict; use utf8; use Apache2::RequestUtil; use POSIX qw(SIGUSR2); sub childInit { # Ignore SIGUSR2 by default my( $mask ) = POSIX::SigSet->new( SIGUSR2 ); my( $action ) = POSIX::SigAction->new( sub{}, $mask ); my( $old )= POSIX::SigAction->new(); POSIX::sigaction(SIGUSR2, $action, $old ); } sub requestInit { # on request redirect SIGUSR2 to "requestCleanup" my( $type ) = shift; my( $req )= shift; my( $self ) = bless [], $type; my( $mask ) = POSIX::SigSet->new( SIGUSR2 ); my( $action ) = POSIX::SigAction->new( sub { $self->writeRequest(); }, $mask ); my( $old )= POSIX::SigAction->new(); POSIX::sigaction(SIGUSR2, $action, $old ); $req->push_handlers(PerlCleanupHandler => sub{ $self->requestCleanup }); push( @$self, $req, $old ); Apache2::Const::OK(); } sub requestCleanup { # after request redirect SIGUSR2 to old "ignore" method my( $self ) = shift; POSIX::sigaction(SIGUSR2, $self->[1]); Apache2::Const::OK(); } sub writeRequest { # print URI to STDERR # perhaps "args" or something can also be applied my( $self ) = shift; my( $req ) = $self->[0]; printf STDERR "SIGUSR2[%s][%s]\n", $$, $req->uri; } 1;
Tool to create multiple requests
Hello, I'm currently developing a huge application with mod_perl, unixODBC and MaxDB/SAPDB. On my developing system everything is fine. But on the productive system with > 50 users, I have database connection errors and request aborts and so on. Now I want to ask if someone knows a tool or perl modules, where I can simulate 50 users. I have a list with some common request including the query parameter in order of appearence. But I don't know, how to send them to my developing system to create the same load as it will be on the productive system. Can someone help me with this issue? Thanks and best regards, Tobias