Skip Menu |

This queue is for tickets about the Apache-DBI CPAN distribution.

Report information
The Basics
Id: 36346
Status: resolved
Priority: 0/
Queue: Apache-DBI

People
Owner: pgollucci [...] p6m7g8.com
Requestors: adam.prime [...] utoronto.ca
Cc: mkent [...] magoazul.com
AdminCc:

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: Apache::DBI 1.07 makes it impossible to fetch data through DBI from startup.pl
using this as my startup.pl use lib qw(/www/perl); use ModPerl::Util (); #for CORE::GLOBAL::exit use Apache2::RequestRec (); use Apache2::RequestIO (); use Apache2::RequestUtil (); use Apache2::ServerRec (); use Apache2::ServerUtil (); use Apache2::Connection (); use Apache2::Const (); use Apache2::Log (); use APR::Table (); use Apache::DBI; use DBI; my $dsn = "dbi:mysql::localhost:3306"; my $user = 'perl'; my $pw = 'xxxxx'; my $dbh = DBI->connect($dsn, $user, $pw); 1; configured like PerlPostConfigRequire /www/conf/startup.pl i get the following in the error_log [Sun Jun 01 23:27:36 2008] [error] Global $r object is not available. Set:\n\tPerlOptions +GlobalRequest\nin httpd.conf at /usr/lib64/perl5/site_perl/5.8.8/Apache/DBI.pm line 144.\nCompilation failed in require at (eval 2) line 1.\n [Sun Jun 01 23:27:36 2008] [error] Can't load Perl file: /www/conf/startup.pl for server pooptop:0, exiting... $r is not available because there is no request occuring. Adding PerlOptions +GlobalRequest has no effect (which is not surprising, since there is no request occuring while startup.pl is running). i'm running: perl -V Summary of my perl5 (revision 5 version 8 subversion 8) configuration: Platform: osname=linux, osvers=2.6.23-gentoo-r6, archname=x86_64-linux uname='linux pooptop 2.6.23-gentoo-r6 #1 sat jan 26 22:06:10 est 2008 x86_64 amd turion(tm) 64 mobile technology mk-36 authenticamd gnulinux ' config_args='-des -Darchname=x86_64-linux -Dcccdlflags=-fPIC -Dccdlflags=-rdynamic -Dcc=x86_64-pc-linux-gnu-gcc -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr -Dlocincpth= -Doptimize=-march=athlon64 -O2 -pipe -Duselargefiles -Dd_semctl_semun -Dscriptdir=/usr/bin -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dinstallman1dir=/usr/share/man/man1 -Dinstallman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3pm -Dinc_version_list=5.8.0 5.8.0/x86_64-linux 5.8.2 5.8.2/x86_64-linux 5.8.4 5.8.4/x86_64-linux 5.8.5 5.8.5/x86_64-linux 5.8.6 5.8.6/x86_64-linux 5.8.7 5.8.7/x86_64-linux -Dcf_by=Gentoo -Ud_csh -Dusenm -Di_ndbm -Di_gdbm -Di_db -Dusrinc=/usr/include/gentoo-multilib/amd64 -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=define use64bitall=define uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='x86_64-pc-linux-gnu-gcc', ccflags ='-fno-strict-aliasing -pipe -Wdeclaration-after-statement -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm', optimize='-march=athlon64 -O2 -pipe', cppflags='-fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/include/gdbm' ccversion='', gccversion='4.1.2 (Gentoo 4.1.2 p1.0.1)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='x86_64-pc-linux-gnu-gcc', ldflags =' -L/usr/local/lib64' libpth=/usr/local/lib64 /lib64 /usr/lib64 libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.6.1.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.6.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic' cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64' Characteristics of this binary (from libperl): Compile-time options: PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO Built under linux Compiled at May 19 2008 22:08:38 @INC: /etc/perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux /usr/lib64/perl5/vendor_perl/5.8.8 /usr/lib64/perl5/vendor_perl /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux /usr/lib64/perl5/site_perl/5.8.8 /usr/lib64/perl5/site_perl /usr/lib64/perl5/5.8.8/x86_64-linux /usr/lib64/perl5/5.8.8 /usr/local/lib/site_perl . libapreq 2.08 mod_perl 2.0.4 httpd 2.2.8
Blast, completely my fault for not testing it. http://rt.cpan.org/Public/Bug/Display.html?id=29209 Seems to have caused it. I'll look at it on Monday (its 1am my time), if I can't figure it out, I'll just revert it and release 1.08. Sorry for the hassle.
From: lubo.rintel [...] gooddata.com
On Mon Jun 02 00:56:49 2008, PGOLLUCCI wrote: Show quoted text
> I'll look at it on Monday (its 1am my time), if I can't figure it out, > I'll just revert it and release 1.08.
I'm wondering if you have a fix for the issue? What we've done to address the issue was to simply eval {} it, which fixes the no-http-request issue, but I doubt it is correct for mod_perl 1.x and would break rollback for people w/o global apache request handler. diff -up Apache-DBI-1.07/lib/Apache/DBI.pm.noreq Apache-DBI-1.07/lib/Apache/DBI.pm --- Apache-DBI-1.07/lib/Apache/DBI.pm.noreq 2008-12-10 15:38:53.000000000 +0100 +++ Apache-DBI-1.07/lib/Apache/DBI.pm 2008-12-10 15:40:50.000000000 +0100 @@ -141,7 +141,9 @@ sub connect { if (!$Rollback{$Idx}) { my $r; if (MP2) { - $r = Apache2::RequestUtil->request; + # We may not actually be in a request, but in <Perl> (or + # equivalent such as startup.pl), in which case this would die. + eval {$r = Apache2::RequestUtil->request }; } elsif (Apache->can('push_handlers')) { $r = 'Apache'; Thanks!
From: ek [...] univie.ac.at
On Mon Jun 02 00:56:49 2008, PGOLLUCCI wrote: Show quoted text
> I'll look at it on Monday (its 1am my time), if I can't figure it out, > I'll just revert it and release 1.08.
Hi! I was wondering about that new release. We have a similar problem with a PerlProcessConnectionHandler, which does not have a Request-object either and have to apply local patches currently. Is there any chance we can get rid of that in the near future? Thanks, Heinz
On Mon Jun 02 00:56:49 2008, PGOLLUCCI wrote: Show quoted text
> Blast, completely my fault for not testing it. > > http://rt.cpan.org/Public/Bug/Display.html?id=29209 > > Seems to have caused it.
Yes, I sent that patch and it's obviously the culprit. Show quoted text
> I'll look at it on Monday (its 1am my time), if I can't figure it out, > I'll just revert it and release 1.08.
I think it's important to have the PerlCleanupHandler, but there is no way to set it up transparently without the global request object. Note that Apache::DBI checks the restart_count of server right before the offending code. So everything should work if you connect to the DB during startup only when restart_count == 1. But this doesn't work if you want to open a DB connection when restart_count != 1. I don't know if there is a reliable way to detect if Apache is in the startup phase. But why not add the eval like lkundrak suggested?
Hi Philip, This bug is now proving to be more of a problem as Apache::DBI 1.07 is getting included in distributions such as Fedora 10 and 11. A fix (or rollback as version 1.08) would be great! It is a real showstopper if you are using database connections at Apache startup. If you use the following test setup with Apache, setup.pl will run fine the first time and then bail out when restart_count > 1. Apache won't start properly. Putting an eval around DBI->connect() does not seem to be a fix for this particular case. /tmp/startup.pl ================================================================= #! /usr/bin/perl -w use strict; use warnings; use Data::Dumper; use Apache::DBI; #use DBI; eval { DBI->connect('dbi:mysql:database=Test;host=localhost;port=3306', 'test', 'test', {'RaiseError'=>'1'}); }; 1; ================================================================= /etc/httpd/conf.d/Apache_DBI_Test.conf ================================================================= ServerName Apache_DBI_Test User apache Group apache <IfModule !perl_module> LoadModule perl_module modules/mod_perl.so </IfModule> <VirtualHost *:80> PerlConfigRequire /tmp/startup.pl </VirtualHost> ================================================================= Many Thanks Peter Walsham Axomic Ltd
On Wed Dec 10 09:52:17 2008, lkundrak wrote: Show quoted text
> On Mon Jun 02 00:56:49 2008, PGOLLUCCI wrote:
> > I'll look at it on Monday (its 1am my time), if I can't figure it out, > > I'll just revert it and release 1.08.
> > I'm wondering if you have a fix for the issue? What we've done to > address the issue was to simply eval {} it, which fixes the > no-http-request issue, but I doubt it is correct for mod_perl 1.x and > would break rollback for people w/o global apache request handler. > > diff -up Apache-DBI-1.07/lib/Apache/DBI.pm.noreq > Apache-DBI-1.07/lib/Apache/DBI.pm > --- Apache-DBI-1.07/lib/Apache/DBI.pm.noreq 2008-12-10 > 15:38:53.000000000 +0100 > +++ Apache-DBI-1.07/lib/Apache/DBI.pm 2008-12-10 15:40:50.000000000
+0100 Show quoted text
> @@ -141,7 +141,9 @@ sub connect { > if (!$Rollback{$Idx}) { > my $r; > if (MP2) { > - $r = Apache2::RequestUtil->request; > + # We may not actually be in a request, but in <Perl> (or > + # equivalent such as startup.pl), in which case this
would die. Show quoted text
> + eval {$r = Apache2::RequestUtil->request }; > } > elsif (Apache->can('push_handlers')) { > $r = 'Apache'; > > Thanks!
This fixes it for me. Any chance of rolling a new release with this patch?
Show quoted text
> > I'm wondering if you have a fix for the issue? What we've done to > > address the issue was to simply eval {} it, which fixes the > > no-http-request issue, but I doubt it is correct for mod_perl 1.x and > > would break rollback for people w/o global apache request handler. > > > > diff -up Apache-DBI-1.07/lib/Apache/DBI.pm.noreq > > Apache-DBI-1.07/lib/Apache/DBI.pm > > --- Apache-DBI-1.07/lib/Apache/DBI.pm.noreq 2008-12-10 > > 15:38:53.000000000 +0100 > > +++ Apache-DBI-1.07/lib/Apache/DBI.pm 2008-12-10 15:40:50.000000000
> +0100
> > @@ -141,7 +141,9 @@ sub connect { > > if (!$Rollback{$Idx}) { > > my $r; > > if (MP2) { > > - $r = Apache2::RequestUtil->request; > > + # We may not actually be in a request, but in <Perl> (or > > + # equivalent such as startup.pl), in which case this
> would die.
> > + eval {$r = Apache2::RequestUtil->request }; > > } > > elsif (Apache->can('push_handlers')) { > > $r = 'Apache'; > > > > Thanks!
> > This fixes it for me. > > Any chance of rolling a new release with this patch?
This fixes it for me as well. But it was frustrating to struggle with the "PerlOptions +GlobalRequest" red herring before finally finding this bug report. Why can't a new release be rolled with this simple patch? Or at the *very* least, a comment pointing to this bug report to avoid future developer confusion? Is anyone there? :)
Paul Orrock asked me to have a look and I took the patch and pushed it out as v1.08.