r33221 - in /trunk/libima-dbi-perl: Changes META.yml README debian/changelog debian/control debian/copyright debian/watch lib/Ima/DBI.pm
eloy at users.alioth.debian.org
eloy at users.alioth.debian.org
Wed Apr 15 09:52:46 UTC 2009
Author: eloy
Date: Wed Apr 15 09:52:40 2009
New Revision: 33221
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=33221
Log:
new upstream version
Modified:
trunk/libima-dbi-perl/Changes
trunk/libima-dbi-perl/META.yml
trunk/libima-dbi-perl/README
trunk/libima-dbi-perl/debian/changelog
trunk/libima-dbi-perl/debian/control
trunk/libima-dbi-perl/debian/copyright
trunk/libima-dbi-perl/debian/watch
trunk/libima-dbi-perl/lib/Ima/DBI.pm
Modified: trunk/libima-dbi-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/Changes?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/Changes (original)
+++ trunk/libima-dbi-perl/Changes Wed Apr 15 09:52:40 2009
@@ -1,4 +1,8 @@
Revision history for Perl extension Ima::DBI.
+
+0.35 Sun Jun 10 16:36:07 EST 2007
+ - Add checking of PID in database handles to prevent trouble
+ in forked environments (Perrin Harkins and Sam Tregar)
0.34 Mon Sep 5 09:10:37 UTC 2005
- Remove Class::WhiteHole from PREREQs (Alexey Tourbin)
Modified: trunk/libima-dbi-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/META.yml?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/META.yml (original)
+++ trunk/libima-dbi-perl/META.yml Wed Apr 15 09:52:40 2009
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Ima-DBI
-version: 0.34
+version: 0.35
version_from: lib/Ima/DBI.pm
installdirs: site
requires:
@@ -11,4 +11,4 @@
Test::More: 0.18
distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
+generated_by: ExtUtils::MakeMaker version 6.30
Modified: trunk/libima-dbi-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/README?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/README (original)
+++ trunk/libima-dbi-perl/README Wed Apr 15 09:52:40 2009
@@ -197,9 +197,9 @@
%attr is combined with a set of defaults (RaiseError => 1, AutoCommit =>
0, PrintError => 0, Taint => 1). This is a better default IMHO, however
- it does give databases without transactions (such as MySQL) a hard time.
- Be sure to turn AutoCommit back on if your database does not support
- transactions.
+ it does give databases without transactions (such as MySQL when used
+ with the default MyISAM table type) a hard time. Be sure to turn
+ AutoCommit back on if your database does not support transactions.
The actual database handle creation (and thus the database connection)
is held off until a prepare is attempted with this handle.
@@ -418,6 +418,36 @@
warn "DBI failure: $@";
}
+USE WITH MOD_PERL, FASTCGI, ETC.
+ To help with use in forking environments, Ima::DBI database handles keep
+ track of the PID of the process they were openend under. If they notice
+ a change (because you forked a new process), a new handle will be opened
+ in the new process. This prevents a common problem seen in environments
+ like mod_perl where people would open a handle in the parent process and
+ then run into trouble when they try to use it from a child process.
+
+ Because Ima::DBI handles keeping database connections persistent and
+ prevents problems with handles openend before forking, it is not
+ necessary to use Apache::DBI when using Ima::DBI. However, there is one
+ feature of Apache::DBI which you will need in a mod_perl or FastCGI
+ environment, and that's the automatic rollback it does at the end of
+ each request. This rollback provides safety from transactions left
+ hanging when some perl code dies -- a serious problem which could grind
+ your database to a halt with stale locks.
+
+ To replace this feature on your own under mod_perl, you can add
+ something like this in a handler at any phase of the request:
+
+ $r->push_handlers(PerlCleanupHandler => sub {
+ MyImaDBI->rollback();
+ });
+
+ Here "MyImaDBI" is your subclass of Ima::DBI. You could also make this
+ into an actual module and set the PerlCleanupHandler from your
+ httpd.conf. A similar approach should work in any long-running
+ environment which has a hook for running some code at the end of each
+ request.
+
TODO, Caveat, BUGS, etc....
I seriously doubt that it's thread safe.
You can bet cupcackes to sno-cones that much havoc will be wrought
@@ -434,8 +464,8 @@
out SQL statements as they are made as well as mention when database
connections are made, etc...
-MAINTAINER
- Tony Bowden <tony at tmtm.com>
+MAINTAINERS
+ Tony Bowden <tony at tmtm.com> and Perrin Harkins <perrin at elem.com>
ORIGINAL AUTHOR
Michael G Schwern <schwern at pobox.com>
Modified: trunk/libima-dbi-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/debian/changelog?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/debian/changelog (original)
+++ trunk/libima-dbi-perl/debian/changelog Wed Apr 15 09:52:40 2009
@@ -1,3 +1,10 @@
+libima-dbi-perl (0.35-1) UNRELEASED; urgency=low
+
+ * (NOT RELEASED YET) New upstream release
+ * debian/watch: updated to last schema
+
+ -- Krzysztof Krzyżaniak (eloy) <eloy at debian.org> Wed, 15 Apr 2009 11:42:24 +0200
+
libima-dbi-perl (0.34-5) unstable; urgency=low
* debian/control: Added Homepage field, and updated Standards-Version.
Modified: trunk/libima-dbi-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/debian/control?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/debian/control (original)
+++ trunk/libima-dbi-perl/debian/control Wed Apr 15 09:52:40 2009
@@ -1,16 +1,25 @@
Source: libima-dbi-perl
Section: perl
Priority: optional
-Maintainer: Bart Martens <bartm at debian.org>
-Build-Depends: cdbs, debhelper (>= 5)
-Build-Depends-Indep: perl (>= 5.8.0), libdbix-contextualfetch-perl (>= 1.00), libdbi-perl (>= 1.20), libclass-data-inheritable-perl (>= 0.02), libtest-pod-perl, libtest-pod-coverage-perl
-Standards-Version: 3.7.3
+Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
+Uploaders: Bart Martens <bartm at debian.org>,
+ Krzysztof Krzyżaniak (eloy) <eloy at debian.org>
+Build-Depends: cdbs, debhelper (>= 7)
+Build-Depends-Indep: perl (>= 5.8.0), libdbix-contextualfetch-perl (>= 1.00),
+ libdbi-perl (>= 1.20), libclass-data-inheritable-perl (>= 0.02),
+ libtest-pod-perl, libtest-pod-coverage-perl
+Standards-Version: 3.8.1
Homepage: http://search.cpan.org/~tmtm/Ima-DBI/
+Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libima-dbi-perl/
+Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libima-dbi-perl/
+
Package: libima-dbi-perl
Architecture: all
Conflicts: libclass-dbi-perl (<< 0.96)
-Depends: ${perl:Depends}, libdbix-contextualfetch-perl (>= 1.00), libdbi-perl (>= 1.20), libclass-data-inheritable-perl (>= 0.02)
+Depends: ${perl:Depends}, ${misc:Depends},
+ libdbix-contextualfetch-perl (>= 1.00), libdbi-perl (>= 1.20),
+ libclass-data-inheritable-perl (>= 0.02)
Description: Database connection caching and organization
Ima::DBI attempts to organize and facilitate caching and more
efficient use of database connections and statement handles.
Modified: trunk/libima-dbi-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/debian/copyright?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/debian/copyright (original)
+++ trunk/libima-dbi-perl/debian/copyright Wed Apr 15 09:52:40 2009
@@ -3,7 +3,9 @@
It was downloaded from http://search.cpan.org/CPAN/authors/id/T/TM/TMTM/
-Upstream Author: Tony Bowden <tony at tmtm.com>
+Upstream Authors:
+ Tony Bowden <tony at tmtm.com>
+ Perrin Harkins <perrin at elem.com>
Original Author: Michael G Schwern <schwern at pobox.com>
Modified: trunk/libima-dbi-perl/debian/watch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/debian/watch?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/debian/watch (original)
+++ trunk/libima-dbi-perl/debian/watch Wed Apr 15 09:52:40 2009
@@ -1,2 +1,3 @@
version=3
-http://search.cpan.org/CPAN/authors/id/T/TM/TMTM/Ima-DBI-(.*)\.tar\.gz
+http://search.cpan.org/dist/Ima-DBI/ .*/Ima-DBI-v?(\d[\d_.]+)\.(?:tar(?:\.gz|\.bz2)?|tgz|zip)
+
Modified: trunk/libima-dbi-perl/lib/Ima/DBI.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libima-dbi-perl/lib/Ima/DBI.pm?rev=33221&op=diff
==============================================================================
--- trunk/libima-dbi-perl/lib/Ima/DBI.pm (original)
+++ trunk/libima-dbi-perl/lib/Ima/DBI.pm Wed Apr 15 09:52:40 2009
@@ -1,6 +1,6 @@
package Ima::DBI;
-$VERSION = '0.34';
+$VERSION = '0.35';
use strict;
use base 'Class::Data::Inheritable';
@@ -250,9 +250,9 @@
%attr is combined with a set of defaults (RaiseError => 1, AutoCommit
=> 0, PrintError => 0, Taint => 1). This is a better default IMHO,
-however it does give databases without transactions (such as MySQL) a
-hard time. Be sure to turn AutoCommit back on if your database does
-not support transactions.
+however it does give databases without transactions (such as MySQL when
+used with the default MyISAM table type) a hard time. Be sure to turn
+AutoCommit back on if your database does not support transactions.
The actual database handle creation (and thus the database connection)
is held off until a prepare is attempted with this handle.
@@ -306,14 +306,31 @@
}
sub _mk_db_closure {
- my ($class, @connection) = @_;
+ my ($class, $dsn, $user, $pass, $attr) = @_;
+ $attr ||= {};
+
my $dbh;
+ my $process_id = $$;
return sub {
- unless ($dbh && $dbh->FETCH('Active') && $dbh->ping) {
- $dbh = DBI->connect_cached(@connection);
+ # set the PID in a private cache key to prevent us
+ # from sharing one with the parent after fork. This
+ # is better than disconnecting the existing $dbh since
+ # the parent may still need the connection open. Note
+ # that forking code also needs to set InactiveDestroy
+ # on all open handles in the child or the connection
+ # will be broken during DESTROY.
+ $attr->{private_cache_key_pid} = $$;
+
+ # reopen if this is a new process or if the connection
+ # is bad
+ if ($process_id != $$ or
+ not ($dbh && $dbh->FETCH('Active') && $dbh->ping)) {
+ $dbh = DBI->connect_cached($dsn, $user, $pass, $attr);
+ $process_id = $$;
}
return $dbh;
};
+
}
=head2 set_sql
@@ -634,6 +651,35 @@
warn "DBI failure: $@";
}
+=head1 USE WITH MOD_PERL, FASTCGI, ETC.
+
+To help with use in forking environments, Ima::DBI database handles keep
+track of the PID of the process they were openend under. If they notice
+a change (because you forked a new process), a new handle will be opened
+in the new process. This prevents a common problem seen in environments
+like mod_perl where people would open a handle in the parent process and
+then run into trouble when they try to use it from a child process.
+
+Because Ima::DBI handles keeping database connections persistent and
+prevents problems with handles openend before forking, it is not
+necessary to use Apache::DBI when using Ima::DBI. However, there is
+one feature of Apache::DBI which you will need in a mod_perl or FastCGI
+environment, and that's the automatic rollback it does at the end of each
+request. This rollback provides safety from transactions left hanging
+when some perl code dies -- a serious problem which could grind your
+database to a halt with stale locks.
+
+To replace this feature on your own under mod_perl, you can add something
+like this in a handler at any phase of the request:
+
+ $r->push_handlers(PerlCleanupHandler => sub {
+ MyImaDBI->rollback();
+ });
+
+Here C<MyImaDBI> is your subclass of Ima::DBI. You could also make this
+into an actual module and set the PerlCleanupHandler from your httpd.conf.
+A similar approach should work in any long-running environment which has
+a hook for running some code at the end of each request.
=head1 TODO, Caveat, BUGS, etc....
@@ -660,9 +706,9 @@
=back
-=head1 MAINTAINER
-
-Tony Bowden <tony at tmtm.com>
+=head1 MAINTAINERS
+
+Tony Bowden <tony at tmtm.com> and Perrin Harkins <perrin at elem.com>
=head1 ORIGINAL AUTHOR
More information about the Pkg-perl-cvs-commits
mailing list