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

Mailing List Archive: ModPerl: ModPerl

Segfault when connecting during Apache startup with Apache::DBI

 

 

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


list at funkreich

Jun 25, 2008, 2:05 AM

Post #1 of 13 (1511 views)
Permalink
Segfault when connecting during Apache startup with Apache::DBI

We have a mod_perl application that needs to connect to the database during
Apache startup to prefetch some data. The database handle for this is not
stored or re-used in any way.

According to the documentation, Apache::DBI does not cache database connections
made during server startup, so I should be fine. Unfortunately as soon as I
uncomment the lines in my ApacheHandler that connect to the database during
startup the Apache children throw segmentation faults on subsequent requests.

AFAIK the connection made during startup is not supposed to clash with the
connections made on a per-child basis during the handler() method via
DBI->connect() because it never gets cached anyway. But it seems that exactly
that is happening (Apache::DBI correctly warns me with "skipping connection
during server startup, read the docu").

The system looks like this:

- 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

Here's the gdb output for the coredump:

This GDB was configured as "i486-linux-gnu"...
(no debugging symbols found)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".

warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/tls/i686/cmov/libm.so.6...(no debugging symbols
found)...done.
Loaded symbols for /lib/tls/i686/cmov/libm.so.6
Reading symbols from /lib/tls/i686/cmov/libpthread.so.0...(no debugging symbols
found)...done.
Loaded symbols for /lib/tls/i686/cmov/libpthread.so.0
Reading symbols from /lib/tls/i686/cmov/libcrypt.so.1...(no debugging symbols
found)...done.
Loaded symbols for /lib/tls/i686/cmov/libcrypt.so.1
Reading symbols from /usr/lib/libdb-4.4.so...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/libdb-4.4.so
Reading symbols from /usr/lib/libperl.so.5.8...
(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libperl.so.5.8
Reading symbols from /lib/tls/i686/cmov/libdl.so.2...(no debugging symbols
found)...done.
Loaded symbols for /lib/tls/i686/cmov/libdl.so.2
Reading symbols from /lib/tls/i686/cmov/libc.so.6...(no debugging symbols
found)...done.
Loaded symbols for /lib/tls/i686/cmov/libc.so.6
Reading symbols from /usr/lib/libexpat.so.1...(no debugging symbols
found)...done.
Loaded symbols for /usr/lib/libexpat.so.1
Reading symbols from /lib/ld-linux.so.2...
(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /usr/local/lib/perl/5.8.8/auto/Cwd/Cwd.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Cwd/Cwd.so
Reading symbols from /usr/local/lib/perl/5.8.8/auto/List/Util/Util.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/List/Util/Util.so
Reading symbols from /usr/lib/perl/5.8.8/auto/Fcntl/Fcntl.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/Fcntl/Fcntl.so
Reading symbols from /usr/lib/perl/5.8.8/auto/IO/IO.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/IO/IO.so
Reading symbols from /usr/lib/perl5/auto/HTML/Parser/Parser.so...done.
Loaded symbols for /usr/lib/perl5/auto/HTML/Parser/Parser.so
Reading symbols from /usr/lib/perl/5.8.8/auto/File/Glob/Glob.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/File/Glob/Glob.so
Reading symbols from /usr/lib/perl/5.8.8/auto/Data/Dumper/Dumper.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/Data/Dumper/Dumper.so
Reading symbols from /usr/lib/perl/5.8.8/auto/B/B.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/B/B.so
Reading symbols from
/usr/local/lib/perl/5.8.8/auto/Apache/Request/Request.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Apache/Request/Request.so
Reading symbols from /usr/lib/perl5/auto/Apache/Symbol/Symbol.so...done.
Loaded symbols for /usr/lib/perl5/auto/Apache/Symbol/Symbol.so
Reading symbols from /usr/local/lib/perl/5.8.8/auto/DBI/DBI.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/DBI/DBI.so
Reading symbols from /usr/lib/perl/5.8.8/auto/MIME/Base64/Base64.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/MIME/Base64/Base64.so
Reading symbols from /usr/local/lib/perl/5.8.8/auto/Digest/SHA/SHA.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Digest/SHA/SHA.so
Reading symbols from
/usr/local/lib/perl/5.8.8/auto/Apache/Cookie/Cookie.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Apache/Cookie/Cookie.so
Reading symbols from /usr/lib/perl/5.8.8/auto/Sys/Hostname/Hostname.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/Sys/Hostname/Hostname.so
Reading symbols from /usr/lib/perl/5.8.8/auto/Socket/Socket.so...done.
Loaded symbols for /usr/lib/perl/5.8/auto/Socket/Socket.so
Reading symbols from /usr/local/lib/perl/5.8.8/auto/Date/Calc/Calc.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Date/Calc/Calc.so
Reading symbols from /usr/local/lib/perl/5.8.8/auto/Digest/SHA1/SHA1.so...done.
Loaded symbols for /usr/local/lib/perl/5.8.8/auto/Digest/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


list at funkreich

Jun 25, 2008, 2:14 AM

Post #2 of 13 (1464 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

> - 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


list at funkreich

Jun 25, 2008, 2:49 AM

Post #3 of 13 (1460 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

Quoting Tobias Kremer <list [at] funkreich>:

> > - 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


list at funkreich

Jun 25, 2008, 2:54 AM

Post #4 of 13 (1472 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

Quoting André Warnier <aw [at] ice-sa>:
> 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


perrin at elem

Jun 25, 2008, 9:14 AM

Post #5 of 13 (1451 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

On Wed, Jun 25, 2008 at 5:49 AM, Tobias Kremer <list [at] funkreich> wrote:
> 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.

It sound like this is a problem with the new DBD::mysql then, rather
than Apache::DBI. If you want to determine that the problem is the
version and not your compile options, you can compile the Ubuntu
versions yourself and see if they segfault.

Another possibility here is that although Apache::DBI doesn't cache
the connections, your code does. If you put them in globals or
closures during startup and try to use them later, I would expect
segfaults.

- Perrin


akb at thenation

Jun 25, 2008, 11:58 AM

Post #6 of 13 (1451 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

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.


Amiri


On Jun 25, 2008, at 12:14 PM, Perrin Harkins wrote:

> On Wed, Jun 25, 2008 at 5:49 AM, Tobias Kremer <list [at] funkreich>
> wrote:
>> 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.
>
> It sound like this is a problem with the new DBD::mysql then, rather
> than Apache::DBI. If you want to determine that the problem is the
> version and not your compile options, you can compile the Ubuntu
> versions yourself and see if they segfault.
>
> Another possibility here is that although Apache::DBI doesn't cache
> the connections, your code does. If you put them in globals or
> closures during startup and try to use them later, I would expect
> segfaults.
>
> - Perrin


list at funkreich

Jun 25, 2008, 12:44 PM

Post #7 of 13 (1447 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

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


list at funkreich

Jun 27, 2008, 2:51 AM

Post #8 of 13 (1423 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

Quoting Tobias Kremer <list [at] funkreich>:

> 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


Brian.Gaber at PWGSC

Jun 27, 2008, 5:15 AM

Post #9 of 13 (1418 views)
Permalink
RE: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

On AIX 5.2 I am using Perl 5.8.0, MySQL 5.0.51a, Apache 2.2.28, mod_perl
2.04, DBI 1.604 and DBD 4.0007 and it all works good.

--Brian

-----Original Message-----
From: Tobias Kremer [mailto:list [at] funkreich]
Sent: Friday, June 27, 2008 5:51 AM
To: modperl [at] perl
Subject: Re: Segfault when connecting during Apache startup with
Apache::DBI

Quoting Tobias Kremer <list [at] funkreich>:

> 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


perrin at elem

Jun 27, 2008, 10:06 AM

Post #10 of 13 (1407 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

On Fri, Jun 27, 2008 at 5:51 AM, Tobias Kremer <list [at] funkreich> 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.

- Perrin


list at funkreich

Jun 30, 2008, 1:54 AM

Post #11 of 13 (1399 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

Quoting Perrin Harkins <perrin [at] elem>:
> On Fri, Jun 27, 2008 at 5:51 AM, Tobias Kremer <list [at] funkreich> 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


perrin at elem

Jun 30, 2008, 5:48 AM

Post #12 of 13 (1378 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

On Mon, Jun 30, 2008 at 4:54 AM, Tobias Kremer <list [at] funkreich> 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.

> Sometimes
> I'm also seeing this error seconds after restarting the mod_perl Apache - I
> think that there should be only fresh connections then ...

That's a different kind of timeout. I meant you may have a really
slow query that takes too long to read from MySQL, not that the
handles would be stale.

Getting errors right after startup makes it sound more likely that you
are storing the database handles you open during startup and trying to
use them.

- Perrin


frank.maas at cheiron-it

Jun 30, 2008, 7:16 AM

Post #13 of 13 (1389 views)
Permalink
Re: Segfault when connecting during Apache startup with Apache::DBI [In reply to]

On Mon, Jun 30, 2008 at 10:54:20AM +0200, Tobias Kremer wrote:
> Any other ideas? Thanks!

It could be that your query(result) is too large for the
'max_allowed_packet' setting. The mysql-client that is connected to your
process will then silently die, giving the 'Lost mysql...' error as
result. Raising it on your server (in my.cnf or similar) can solve the
problem.

Kind regards,
Frank

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.