Flame has asked for the wisdom of the Perl Monks concerning the following question:

Greetings fellow Monks,

I have been working for quite some time on a school project that runs off of mod_perl and uses a MySQL database, however now I am faced with a... irritating problem. It appears that I have recently introduced a bug that causes the eventual lockup of the Apache threads that try to run it. I base this uppon the following excerpt from the error logs:

DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. DBD::mysql::st execute failed: Can't connect to local MySQL server thr +ough socket '/var/lib/mysql/mysql.sock' (111) at /usr/local/lib/perl5 +/site_perl/5.8.0/Apache/Session/Store/DBI.pm line 86. [Fri May 16 21:57:42 2003] [notice] child pid 1313 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1312 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1311 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1310 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1307 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1267 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1266 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1264 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1256 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1255 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 1254 exit signal Segment +ation fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 959 exit signal Segmenta +tion fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 796 exit signal Segmenta +tion fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 784 exit signal Segmenta +tion fault (11) [Fri May 16 21:57:42 2003] [notice] child pid 764 exit signal Segmenta +tion fault (11) SV = RV(0x8370c70) at 0x8994f60 REFCNT = 1 FLAGS = (PADBUSY,PADMY) [Fri May 16 21:57:46 2003] [warn] child process 763 still did not exit +, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 797 still did not exit +, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 1305 still did not exi +t, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 1306 still did not exi +t, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 1342 still did not exi +t, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 1343 still did not exi +t, sending a SIGTERM [Fri May 16 21:57:46 2003] [warn] child process 1344 still did not exi +t, sending a SIGTERM [Fri May 16 21:59:08 2003] [warn] pid file /usr/local/apache/logs/http +d.pid overwritten -- Unclean shutdown of previous Apache run?

These errors lead me to look at the MySQL database, which I had been using Apache::DBI and DBI upon and I had recently stated using LOCK TABLES ....... upon. In an effort to discover the cause, I removed those lock calls and I later removed Apache::DBI, both with no useful results. The errors above caused me to wonder if one of several things had happened... since Apache was shut down as part of the standard shutdown sequence on the computer (Linux), it is possible that the database was shut down before apache and that the shutdown signals sortof "woke up" the frozen threads and caused them to try to finish what they had started, thus the inability to connect to mysql messages, but beyond that I couldn't come up with anything.

Now while I'd normally use debug mode or Devel::Ptkdb to trace a problem like this, since this was designed around mod_perl, I'm not sure how to simulate the mod_perl environment so that I can actually test it. Is there some method of simulating it for this purpose, or is there some other method of debugging I should try?

Thank you for taking the time to read this, it's rather poorly worded I realize. If anyone wishes to view the source code for my project, just ask and I'll post it to my scratchpad... if it will fit. (Too large to put here practically anyway... 90kb would be rather inconvenient)



My code doesn't have bugs, it just develops random features.

Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

Replies are listed 'Best First'.
(UPDATE) debugging mod_perl?
by Flame (Deacon) on May 18, 2003 at 03:04 UTC
    Well, I've found something that may allow me to use the Perl debugger, Apache::DB. However now that I'm trying to use it I can't seem to load apache, I get the following error:
    [root@slinux bin]# ./httpd -X -D PERLDB [notice] Apache::DB initialized in child 2257 Syntax Error on line 999 of /usr/local/apache/conf/httpd.conf: No DB::DB routine defined at /usr/local/lib/perl5/5.8.0/Exporter/Heavy +.pm line 4. BEGIN failed--compilation aborted at /usr/local/lib/perl5/5.8.0/Export +er/Heavy.pm line 4. Compilation failed in require at /usr/local/lib/perl5/5.8.0/Export.pm +line 16. BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/i6 +86-linux-thread-multi/DBI.pm line 255. Compilation failed in require at (eval 8) line 3.

    With that Apache dies. The following is lines 983 - 994:
    <IfDefine PERLDB> #Line 983 <Perl> use Apache::DB (); Apache::DB->init; </Perl> <Location /> PerlFixupHandler Apache::DB </Location> </IfDefine> #Line 994

    I'm at a bit of a loss to explain this since I've never corectally set it up before. The code above is essentially a copy-paste from one of the mod_perl docs that talks about debugging.

    Thanks for any advice you can give.



    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

      Apache::DB has worked for me in the past. However, I've never tried it with perl 5.8. Is it possible for you to try this with 5.6.1?
Re: debugging mod_perl?
by perrin (Chancellor) on May 19, 2003 at 04:31 UTC
    Are you saying this happened during a shutdown? If so, don't worry about it. If this happened during normal page-serving, when MySQL was up and appeared to be okay, you should be concerned. One thing you might want to try is connecting via TCP instead of local sockets.
      Those errors were primaraly from threads that somehow froze and were forced to quit during shutdown. Apache::Session tried to save the data from the tied hash and failed because the database had already been shut down... at least that's my interpretation.



      My code doesn't have bugs, it just develops random features.

      Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

        Hmmm. Why is your server being shut down in the middle of handling requests? Are you sure that you're completely destroying the session object every time? You could have a scoping problem that prevents Apache::Session from saving.