Re: DBI and Apache::DBI issues

2011-02-08 Thread Perrin Harkins
On Sun, Feb 6, 2011 at 4:44 PM, Max Pinton m...@designyourowncard.com wrote:
 Did earlier versions of Perl/mod_perl/DBI/Apache::DBI handle closures
 differently?

No, not at all.  This is a core Perl thing.

 I'm just curious why it used to work. It seems like DBI would
 reconnect a $dbh closure if it timed out.

One thing that might have changed is your database configuration.
MySQL is often configured to automatically reconnect.

That doesn't explain all of your errors though.  I'm guessing that
you're opening a connection during startup and forking with it.  You
need to find that.  Look for things that might open a connection
during startup and move them to ChildInitHandlers instead.

- Perrin


Re: DBI and Apache::DBI issues

2011-02-08 Thread Max Pinton

On Feb 8, 2011, at 7:36 AM, Perrin Harkins wrote:

I'm just curious why it used to work. It seems like DBI would
reconnect a $dbh closure if it timed out.


One thing that might have changed is your database configuration.
MySQL is often configured to automatically reconnect.


I checked $dbh-{mysql_auto_reconnect} and, as per the docs, it's 1 in  
a mod_perl script and 0 otherwise. Is there another place to look? It  
seems like something I'd really want to have on.



That doesn't explain all of your errors though.  I'm guessing that
you're opening a connection during startup and forking with it.  You
need to find that.  Look for things that might open a connection
during startup and move them to ChildInitHandlers instead.


That's puzzling. I'm not forking anywhere in my scripts. I did once  
try using threads for something, but abandoned it because it  
segfaulted in mod_perl and it wasn't db-related anyway. My  
startup.perl (minus my modules) is:


#!/usr/bin/perl
use strict;

# make sure we are in a sane environment.
$ENV{MOD_PERL} or die not running under mod_perl!;

use ModPerl::Registry ();

# Apache::DBI must be before DBI
#use Apache::DBI ();
use DBI ();

use CGI '-no_xhtml';
CGI-compile(':all');
use GD ();
use MIME::Base64 ();
use Data::Dumper ();
use XML::Simple ();
use XML::Writer ();
use File::Temp;

1;

Does anything there look fishy?

Thanks,

Max



Re: DBI and Apache::DBI issues

2011-02-08 Thread Alex Hunsaker
On Tue, Feb 8, 2011 at 16:26, Max Pinton m...@designyourowncard.com wrote:
 On Feb 8, 2011, at 7:36 AM, Perrin Harkins wrote:
 That doesn't explain all of your errors though.  I'm guessing that
 you're opening a connection during startup and forking with it.  You
 need to find that.  Look for things that might open a connection
 during startup and move them to ChildInitHandlers instead.

 That's puzzling. I'm not forking anywhere in my scripts. I did once try
 using threads for something, but abandoned it because it segfaulted in
 mod_perl and it wasn't db-related anyway. My startup.perl (minus my modules)
 is:

You could always try strace to find if there are any fork/clone calls:
strace -e trace=fork,clone httpd -X

 [startup.perl]

 Does anything there look fishy?

Nothing jumps out at me.


Re: DBI and Apache::DBI issues

2011-02-08 Thread Perrin Harkins
On Tue, Feb 8, 2011 at 6:26 PM, Max Pinton m...@designyourowncard.com wrote:
 I checked $dbh-{mysql_auto_reconnect} and, as per the docs, it's 1 in a
 mod_perl script and 0 otherwise. Is there another place to look? It seems
 like something I'd really want to have on.

Recommended practice is to turn this off.  If it's on and you lose
your connection for some reason in the middle of handling a web
request, the client will try to reconnect and keep going with the rest
of the request.  That's almost certainly not what you want in any
situation where data is modified.

Apache::DBI or DBI-connect_cached() are better because they only
reconnect when you tell them to, at the beginning of the requests.
However, this means that if you use Apache::DBI you MUST call
DBI-connect() at the beginning of every request and not cache the
$dbh objects yourself.


 That doesn't explain all of your errors though.  I'm guessing that
 you're opening a connection during startup and forking with it.  You
 need to find that.  Look for things that might open a connection
 during startup and move them to ChildInitHandlers instead.

 That's puzzling. I'm not forking anywhere in my scripts.

I meant apache forking child processes after startup.

 My startup.perl (minus my modules)

The problem in this case would be in your modules.  One of them
probably opens a database connection for some reason.  You can see it
happen by using DBI_TRACE.

- Perrin


Re: DBI and Apache::DBI

2004-05-14 Thread MARTIN MOSS
You didn't specify which Database server you're using. If it's mysql you need to be cautious of the 'ping' method used by Apache::DBI to check if a connection is stale or not. the DBD::mysql ping method always returns a 'true' string e.g. "0 but true" rather than a 1 or a 0.

I believe the latest version of DBD::mysql has an automatic 'reconnect' feature, but We're still seeing failed connections occuring infrequently on our systems. (Still investigating).

MartyPerrin Harkins [EMAIL PROTECTED] wrote:
On Wed, 2004-05-12 at 12:15, I S wrote: a) I don't understand why the database sometimes gets dropped. It happens randomly but frequently.  could not prepare: Database disconnected at /dssweb/httpd/cgi-bin/feeds/viewReport line 157.Usually this is caused by an inactivity timeout on your databaseserver. If you call DBI-connect before that, Apache::DBI will ping theconnection to make sure it is still live and re-connect if it isn't. b) I built mod_perl and apache with EVERYTHING=1.  Should I expect DBI.pm appear in Apache directory?EVERYTHING=1 affects which hooks are enabled for mod_perl handlers. Ithas nothing to do with which modules will be available.Apache::DBI comes with mod_perl, and you should see it in your site_perldirectory. It is a pure perl module, so it would not be
 under an i386directory (or whatever your architecture is). If you can do PerlModuleApache::DBI in your program without failure, it means that it is therein your @INC path.- Perrin-- Report problems: http://perl.apache.org/bugs/Mail list info: http://perl.apache.org/maillist/modperl.htmlList etiquette: http://perl.apache.org/maillist/email-etiquette.html

Re: DBI and Apache::DBI

2004-05-14 Thread Perrin Harkins
[ Please keep it on the list... ]

On Fri, 2004-05-14 at 09:36, Alex McLintock wrote:
 sometimes at random my mod_perl/DBI/DBD::Mysql connections fail at 
 the execute stage resulting in an error something like fetch failed 
 because of no execute failure.
 
 Does this sound like the same problem you are seeing. As far as I know 
 the prepare is working and I don't get the Database disconnected 
 message.

Do you have RaiseError turned on?  That message normally means you
missed a step or something failed earlier and you didn't notice.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: DBI and Apache::DBI

2004-05-12 Thread Erik Scholtz, ArgonSoft GmbH
I S wrote:

Hi all,

I have some questions with DBI. 

a) I don't understand why the database sometimes gets
dropped.  It happens randomly but frequently.
could not prepare: Database disconnected at
/dssweb/httpd/cgi-bin/feeds/viewReport line 157.
b) I built mod_perl and apache with EVERYTHING=1.  
Should I expect  DBI.pm appear in Apache directory?  
For some reason, it doesn't get there.  Or should I
add DBI module under Apached directory?  If so, how.  
I have my own version of Perl under home directory.

Thanks, 
Isarin  

Hello,

DBI.pm should normaly be in the tree of your perl-installation (where 
all global modules are stored). Your httpd.conf should contain the 
following lines in the config of your domain:

LoadModule perl_module modules/mod_perl.so
PerlModule Apache2
PerlModule Apache::DBI
Perhaps it would be easier for us to help you, if you would include the 
necessary part of your script.



Erik

-
ArgonSoft GmbH  | Im Ermlisgrund 3  | 76337 Waldbronn
Tel: +49 7243 71520 | Fax: +49 7243 715222  | http://www.argonsoft.de
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: DBI and Apache::DBI

2004-05-12 Thread Perrin Harkins
On Wed, 2004-05-12 at 12:15, I S wrote:
 a) I don't understand why the database sometimes gets
 dropped.  It happens randomly but frequently.
 
 could not prepare: Database disconnected at
 /dssweb/httpd/cgi-bin/feeds/viewReport line 157.

Usually this is caused by an inactivity timeout on your database
server.  If you call DBI-connect before that, Apache::DBI will ping the
connection to make sure it is still live and re-connect if it isn't.

 b) I built mod_perl and apache with EVERYTHING=1.  
 Should I expect  DBI.pm appear in Apache directory?

EVERYTHING=1 affects which hooks are enabled for mod_perl handlers.  It
has nothing to do with which modules will be available.

Apache::DBI comes with mod_perl, and you should see it in your site_perl
directory.  It is a pure perl module, so it would not be under an i386
directory (or whatever your architecture is).  If you can do PerlModule
Apache::DBI in your program without failure, it means that it is there
in your @INC path.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: DBI and Apache::DBI

2004-05-12 Thread I S
 Apache::DBI comes with mod_perl, and you should see
 it in your site_perl directory.  It is a pure perl 
 module, so it would not be under an i386
 directory (or whatever your architecture is).  If
 you can do PerlModule Apache::DBI in your program 
 without failure, it means that it is there
 in your @INC path.

Sorry for being unclear.  I mean Apache subdirectory
under site_perl directory.  I can seee Registry.pm
under .../site_perl/5.8.3/sun4-solaris/Apache
directory. (Apache::Registry)  I would expect DBI in
the same directory but it is not there.   I figured
that out after it gave me an error that it can't find
Apache::DBI.

I am not sure what I missed when building mod_perl /
Apache.   Do I need to add environmental variables?


Let me recap what I did:

a) Build perl under my home directory
 /home/dssweb/local-perl 

b) Add DBI module and others 
   other modules such as LWP, HTTP are under:
  /home/dssweb/local-perl/lib/site_perl/5.8.3
   
   yet my DBI module is under:
/home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solaris


c) Build mod_perl and apache.  

My mod_perl and some Apache stuff are under 
/home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solaris


Thanks.

 





__
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: DBI and Apache::DBI

2004-05-12 Thread Brent 'Dax' Royal-Gordon
I S wrote:
Sorry for being unclear.  I mean Apache subdirectory
under site_perl directory.  I can seee Registry.pm
under .../site_perl/5.8.3/sun4-solaris/Apache
directory. (Apache::Registry)  I would expect DBI in
the same directory but it is not there.   I figured
that out after it gave me an error that it can't find
Apache::DBI.
Try .../site_perl/Apache and .../site_perl/5.8.3/Apache.  Also, if you 
originally installed mod_perl with an older version of Perl, check its 
folders.

--
Brent Dax Royal-Gordon [EMAIL PROTECTED]
Perl and Parrot hacker
Oceania has always been at war with Eastasia.

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: DBI and Apache::DBI

2004-05-12 Thread Perrin Harkins
On Wed, 2004-05-12 at 14:32, I S wrote:
 Sorry for being unclear.  I mean Apache subdirectory
 under site_perl directory.  I can seee Registry.pm
 under .../site_perl/5.8.3/sun4-solaris/Apache
 directory. (Apache::Registry)  I would expect DBI in
 the same directory but it is not there.

That's what I was saying: Apache::DBI is pure perl, so it doesn't go in
that directory.  Look in /site_perl/5.8.3/Apache instead.

 I figured
 that out after it gave me an error that it can't find
 Apache::DBI.

If you have Apache::Registry installed, you should also have Apache::DBI
installed.  Look for it with find or locate, and check the permissions
on the directories above it.

 b) Add DBI module and others 
other modules such as LWP, HTTP are under:
   /home/dssweb/local-perl/lib/site_perl/5.8.3

yet my DBI module is under:
 /home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solaris

Are you talking about DBI, not Apache::DBI?  That's an XS module so it
goes into the architecture-dependent directory.

 My mod_perl and some Apache stuff are under 
 /home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solaris

Then you should find Apache/DBI.pm under
/home/dssweb/local-perl/lib/site_perl/5.8.3.

- Perrin


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Re: DBI and Apache::DBI

2004-05-12 Thread I S
Thanks, Guys,

I ended upinstalling Apache::DBI from CPAN and it isunder /home/dssweb/local-perl/lib/site_perl/5.8.3. I was mistaken that Apache::DBI would come with apache.
Event though it was, for some reason it didn't get installed.

Anyways, it is working now.

Cheers, Isarin
Perrin Harkins [EMAIL PROTECTED] wrote:
On Wed, 2004-05-12 at 14:32, I S wrote: Sorry for being unclear. I mean Apache subdirectory under site_perl directory. I can seee Registry.pm under .../site_perl/5.8.3/sun4-solaris/Apache directory. (Apache::Registry) I would expect DBI in the same directory but it is not there.That's what I was saying: Apache::DBI is pure perl, so it doesn't go inthat directory. Look in /site_perl/5.8.3/Apache instead. I figured that out after it gave me an error that it can't find Apache::DBI.If you have Apache::Registry installed, you should also have Apache::DBIinstalled. Look for it with find or locate, and check the permissionson the directories above it. b) Add DBI module and others  other modules such as LWP, HTTP are under:
 /home/dssweb/local-perl/lib/site_perl/5.8.3  yet my DBI module is under: /home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solarisAre you talking about DBI, not Apache::DBI? That's an XS module so itgoes into the architecture-dependent directory. My mod_perl and some Apache stuff are under  /home/dssweb/local-perl/lib/site_perl/5.8.3/sun4-solarisThen you should find Apache/DBI.pm under/home/dssweb/local-perl/lib/site_perl/5.8.3.- Perrin-- Report problems: http://perl.apache.org/bugs/Mail list info: http://perl.apache.org/maillist/modperl.htmlList etiquette: http://perl.apache.org/maillist/email-etiquette.html
		Do you Yahoo!?Yahoo! Movies - Buy advance tickets for 'Shrek 2'