Re: Ima::DBI and connections at Apache startup
[prev]
[thread]
[next]
[Date index for 2004/10/06]
On Wed, Oct 06, 2004 at 03:01:43PM +1000, Brad Bowman wrote:
>
> > > Another BIG hitch with my plan is that Class::DBI needs to
> > > consistently get the same handle from db_Main for transactions
> > > to work.
> >
> > That shouldn't be a problem at all. You always get the same handle in
> > the same process when you use connect_cached/Apache::DBI and send the
> > same connect string.
>
> That's what I expected, but it didn't seem that way in my tests (below)
>
> AutoCommit seems to be reset at DBI.pm line 640 in 'connect'
> after the cache is hit. This would also effect Apache::DBI::connect.
That's an interesting observation.
> I guess this is to ensure the handle is in the state expected from
> the given attributes (& defaults) but it does have the side effect
> of breaking transactions when you don't connect with AutoCommit = 1,
> and later "begin_work".
>
> I guess "Don't do that" is the answer. Perhaps the reseting
> code should warn you if AutoCommit isn't the same.
I can argue it either way. Really DBI->connect is doing too much and
some of the logic ought to be done by $drh->connect, which would
then mean the handle returned by $drh->connect_cached would not
need be "mucked about with" by DBI->connect. This is an area that
may change in DBI v2.0.
Tim.
> @c = ('XXX','XXX','XXX',{AutoCommit=>1});
>
> DB<2> x $a = DBI->connect_cached(@c);
> 0 DBI::db=HASH(0x83fb060)
> empty hash
> DB<3> x $a->{Active}
> 0 1
> DB<4> x $a->{AutoCommit}
> 0 1
> DB<5> x $a->begin_work
> 0 1
> DB<6> x $a->{AutoCommit}
> 0 ''
> DB<7> x $a->rollback
> 0 1
> DB<8> x DBI->connect_cached(@c)->{AutoCommit}
> 0 1
> DB<9> x DBI->connect_cached(@c)->begin_work
> 0 1
> DB<10> x DBI->connect_cached(@c)->{AutoCommit}
> 0 1
> DB<11> x DBI->connect_cached(@c)->rollback
> rollback ineffective with AutoCommit enabled at (eval 14)[/usr/share/perl/5.6.1/perl5db.pl:1521] line 2.
> Rollback ineffective while AutoCommit is on at (eval 14)[/usr/share/perl/5.6.1/perl5db.pl:1521] line 2.
> DBD::mysql::db rollback failed: Rollback ineffective while AutoCommit is on at (eval 14)[/usr/share/perl/5.6.1/perl5db.pl:1521] line 2.
> 0 ''
> DB<12> x DBI->connect_cached(@c)->{Driver}{CachedKids}
> 0 HASH(0x842f11c)
> 'XXX:localhost~~XXX~~XXX~~AutoCommit~~PrintError~~Username~~dbi_connect_method~~1~~1~~www-data~~connect_cached' => DBI::db=HASH(0x83fb060)
> empty hash
>
>
>
> --
> Among the maxims on Lord Naoshige's wall there was this one: "Matters
> of great concern should be treated lightly." Master Ittei commented,
> "Matters of small concern should be treated seriously."
> -- Hagakure http://bereft.net/hagakure/
>
|
(message missing)
|