Re: CDBI and mod_perl

[prev] [thread] [next] [Date index for 2005/02/10]

From: Edward J. Sabol
Subject: Re: CDBI and mod_perl
Date: 23:42 on 10 Feb 2005
> Rather than ask you to repeat yourself, I'll see if I've found your  
> previous advice. Is this what you're talking about?  
> <http://mathforum.org/epigone/modperl/teuthocrix/1098821949.2903.49.camel@xxxxxxxxx.xxxxxxxxxxx>;

We should really have a Wiki node on this topic! Better yet, let's get a
proper solution incorporated into Ima::DBI and Apache::DBI....

For getting automatic rollbacks working, I propose the following solution
which requires modifying Apache::DBI. First, add the following sub to
Apache/DBI.pm:

sub modperl_cleanup {
    my $prefix = "$$ Apache::DBI            ";
    print STDERR "$prefix PerlCleanupHandler \n" if $Apache::DBI::DEBUG > 1;
    my $dbh = $Connected{$Idx};
    if ($dbh and $dbh->{Active} and !$dbh->{AutoCommit} and eval {$dbh->rollback}) {
        print STDERR "$prefix PerlCleanupHandler rollback for $Idx \n" if $Apache::DBI::DEBUG > 1;
    }
    1;
}

You might notice that this is rather similar to Apache::DBI::cleanup(), but
the logic is somewhat different. Apache::DBI::cleanup() only rolls back when
$Apache::DBI::Rollback{$Idx} is set which, due to the way Ima::DBI works,
only happens on the first request.

Then, in your mod_perl httpd.conf file, add the following:

PerlCleanupHandler Apache::DBI::modperl_cleanup

That fix should work with all DBI connections, not just Class::DBI stuff, I
believe.

In an off-list e-mail discussion that Perrin and I had on this topic a few
months ago, Perrin suggested a simpler solution:

$r->push_handlers(PerlCleanupHandler => sub {
    MyClassDBI->dbi_rollback();
});

where MyClassDBI is the base class of your Class::DBI modules.

(message missing)

Column Names
Justin Tocci 05:19 on 10 Feb 2005

Re: Column Names
Peter Speltz 20:36 on 10 Feb 2005

Re: Column Names
Rod McChesney 20:56 on 10 Feb 2005

CDBI and mod_perl
Rod McChesney 20:58 on 10 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:37 on 10 Feb 2005

Re: CDBI and mod_perl
Drew Wilson 21:54 on 10 Feb 2005

Re: CDBI and mod_perl
karjala_lists 13:59 on 15 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:16 on 10 Feb 2005

Re: CDBI and mod_perl
Drew Wilson 22:27 on 10 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:46 on 10 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 23:42 on 10 Feb 2005

Re: CDBI and mod_perl
Rod McChesney 01:55 on 12 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 19:43 on 12 Feb 2005

Re: CDBI and mod_perl
Rod McChesney 18:48 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:23 on 14 Feb 2005

Re: CDBI and mod_perl
Edward J. Sabol 06:53 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:14 on 14 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 19:59 on 15 Feb 2005

Re: CDBI and mod_perl
Tim Bunce 22:33 on 15 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 22:12 on 18 Feb 2005

Re: CDBI and mod_perl
=?ISO-8859-1?Q?Ask_Bj=F8rn_Hansen?= 22:19 on 18 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 22:36 on 18 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 11:23 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 13:56 on 19 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 15:57 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 16:21 on 19 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 16:24 on 19 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 09:54 on 20 Feb 2005

Re: CDBI and mod_perl
Perrin Harkins 21:31 on 20 Feb 2005

Re: CDBI and mod_perl
Tony Bowden 22:19 on 20 Feb 2005

Generated at 12:48 on 22 Feb 2005 by mariachi v0.52