Re: [Catalyst] do I need to load Apache::DBI?

2007-07-31 Thread Perrin Harkins
On 7/31/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> Except in the DBIx::Class, Class::DBI and plain DBI apps I've brought back
> to production quality stability by removing it.

DBIx::Class and Class::DBI both handle connection caching on their
own, so that is not where one would need Apache::DBI.  It's meant to
be used with plain DBI apps that aren't already doing connection
caching.  I will get the Apache::DBI docs updated to make this clear.

> There's no "implication" - sometimes it doesn't work. Mostly it does. 
> Producing
> a repeatable test case has proven pretty much impossible due to the hackiness
> of the implementation.

Usually when people have trouble it's due to clashes with some other
code that was trying to cache connections.  If you find a situation
like this again, a bug report of some kind would be appreciated.

- Perrin

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-31 Thread Matt S Trout
On Mon, Jul 30, 2007 at 06:19:09PM -0400, Perrin Harkins wrote:
> On 7/30/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> > I used to consider it a neat hack. After some time with the internals,
> > some fun explicitly disabling it within DBIC since it sometimes broke our
> > reconnect code, and even then discovering I could often solve client 
> > mod_perl
> > problems by removing the line that loaded it from httpd.conf, I reclassified
> > it was 'awful'.
> 
> Your implication is that Apache::DBI doesn't work, as opposed to
> simply clashing with some of the DBIC code that tries to manage the
> same connections.  It works just fine.  It's widely-used and does what
> it was intended to without known bugs.

Except in the DBIx::Class, Class::DBI and plain DBI apps I've brought back
to production quality stability by removing it.

There's no "implication" - sometimes it doesn't work. Mostly it does. Producing
a repeatable test case has proven pretty much impossible due to the hackiness
of the implementation. Since I usually -can- modify the calling code I
just switch it over to using a DBIC storage object to manage the $dbh and
move on.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-30 Thread Perrin Harkins
On 7/30/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> I used to consider it a neat hack. After some time with the internals,
> some fun explicitly disabling it within DBIC since it sometimes broke our
> reconnect code, and even then discovering I could often solve client mod_perl
> problems by removing the line that loaded it from httpd.conf, I reclassified
> it was 'awful'.

Your implication is that Apache::DBI doesn't work, as opposed to
simply clashing with some of the DBIC code that tries to manage the
same connections.  It works just fine.  It's widely-used and does what
it was intended to without known bugs.

Apache::DBI provides an important service for people trying to port
CGI code to mod_perl, by both making their connections persistent and
fixing the most common mistakes in homegrown persistent connections
(accidental copying across forks, ping check after inactivity, auto
cleanup after crashed requests).

The implementation is sneakier than I normally like to see because not
requiring client code changes is one of its design goals.  For that
reason, I wouldn't recommend it to people who are starting fresh with
a new codebase and are able to write it specifically for a persistent
environment like mod_perl.  Most of them will use another tool that
already handles connection persistence, like an ORM.

If someone out there wants to use DBIC (or another tool that manages
its own connections) in the same process as some code that needs
Apache::DBI, they should feel free to ask for help on the mod_perl
list.  I don't think it would be a hard problem to fix.

- Perrin

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-30 Thread Jonathan T. Rockway
On Mon, Jul 30, 2007 at 06:19:09PM -0400, Perrin Harkins wrote:
> On 7/30/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> > I used to consider it a neat hack. After some time with the internals,
> > some fun explicitly disabling it within DBIC since it sometimes broke
> > our reconnect code, and even then discovering I could often solve
> > client mod_perl problems by removing the line that loaded it from
> > httpd.conf, I reclassified it was 'awful'.
>
> Your implication is that Apache::DBI doesn't work, as opposed to
> simply clashing with some of the DBIC code that tries to manage the
> same connections.  It works just fine.  It's widely-used and does what
> it was intended to without known bugs.

I think mst's point was "if you don't know why to use Apache::DBI,
don't use it".  Generally good advice.

Regards,
Jonathan Rockway

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-30 Thread Matt S Trout
On Mon, Jul 30, 2007 at 11:04:27AM -0400, Perrin Harkins wrote:
> On 7/24/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> > Apache::DBI is an awful hack and should be avoided where possible.
> 
> Kind of an exaggeration.  Apache::DBI is a useful module for porting
> existing CGI scripts to mod_perl.  If you aren't porting CGI scripts
> to mod_perl, you

... don't need an awful hack to get a persistent DB connection :)

I used to consider it a neat hack. After some time with the internals,
some fun explicitly disabling it within DBIC since it sometimes broke our
reconnect code, and even then discovering I could often solve client mod_perl
problems by removing the line that loaded it from httpd.conf, I reclassified
it was 'awful'.

So from where I'm standing, it's not an exaggeration at all.

I guess if you're not using something with smart reconnect logic like
DBIC, it's a different matter. I can't figure out where the equivalent code
is in RDBO so I've no idea how intelligent it is.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/http://www.shadowcat.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-30 Thread Perrin Harkins
On 7/24/07, Matt S Trout <[EMAIL PROTECTED]> wrote:
> Apache::DBI is an awful hack and should be avoided where possible.

Kind of an exaggeration.  Apache::DBI is a useful module for porting
existing CGI scripts to mod_perl.  If you aren't porting CGI scripts
to mod_perl, you can use other tools like DBI->connect_cached instead.
 The main differences are that Apache::DBI disables disconnect(), to
allow for porting CGI code that disconnects after every request, and
Apache::DBI does a rollback at the end of every request to avoid
accidental commits of bad data when code dies during a request.

- Perrin

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-24 Thread Matt S Trout
On Tue, Jul 24, 2007 at 09:20:00AM +0200, Cédric Bouvier wrote:
> Hello,
> 
> I have failed to understand something. If I run my Catalyst application
> under mod_perl, will it automatically use persistent database
> connections, or do I have to explicitely tell mod_perl to load
> Apache::DBI?

Catalyst has exactly no effect on database connections. It's a web framework.
You might not even be using a database.

DBIx::Class and Catalyst::Model::DBI both maintain persistent connections
themselves though.

Apache::DBI is an awful hack and should be avoided where possible.

-- 
  Matt S Trout   Need help with your Catalyst or DBIx::Class project?
   Technical DirectorWant a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/ 

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-24 Thread Bill Moseley
On Tue, Jul 24, 2007 at 04:47:14PM +0400, Oleg Pronin wrote:
> Under mod_perl all calls to DBI are proxied to Apache::DBI

No, Apache::DBI isn't used automatically.


# check if user wants a persistent database connection ( Apache + mod_perl )
if ($INC{'Apache/DBI.pm'} && $ENV{MOD_PERL}) {
$DBI::connect_via = "Apache::DBI::connect";
DBI->trace_msg("DBI connect via $DBI::connect_via in 
$INC{'Apache/DBI.pm'}\n");
}


-- 
Bill Moseley
[EMAIL PROTECTED]


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] do I need to load Apache::DBI?

2007-07-24 Thread Oleg Pronin

Under mod_perl all calls to DBI are proxied to Apache::DBI

2007/7/24, Cédric Bouvier <[EMAIL PROTECTED]>:


Hello,

I have failed to understand something. If I run my Catalyst application
under mod_perl, will it automatically use persistent database
connections, or do I have to explicitely tell mod_perl to load
Apache::DBI?

TIA

--
C é d r i c   B o u v i e r

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGpaggV+dbgD38PGgRArYIAJ9J51KG2nLydwKVCy5Hu2V7mWFGmwCgpPQL
HqmfvuCkPXFiI8aDXVrm6jU=
=+26Z
-END PGP SIGNATURE-

___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] do I need to load Apache::DBI?

2007-07-24 Thread Cédric Bouvier
Hello,

I have failed to understand something. If I run my Catalyst application
under mod_perl, will it automatically use persistent database
connections, or do I have to explicitely tell mod_perl to load
Apache::DBI?

TIA

-- 
C é d r i c   B o u v i e r


signature.asc
Description: Digital signature
___
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/